简体   繁体   English

使用符号链接linux时如何使原始文件不被删除

[英]How to make original file not delete when using symbolic link linux

I want to ask when I delete file in folder symlink target, is it possible make the file is still available in original file?我想问当我删除文件夹符号链接目标中的文件时,是否可以使文件在原始文件中仍然可用? I use ls -n /folder /target but when I delete file in /target , in original folder deleted too.我使用ls -n /folder /target但是当我删除/target中的文件时,原始文件夹中的文件也被删除了。

Remove Symbolic Links with rm使用rm删除符号链接

rm symlink_name

Remove Symbolic Links with unlink使用unlink删除符号链接

unlink symlink_name

Unlink command and rm command without -R option doesn't delete regular directory.不带-R选项的Unlink命令和rm命令不会删除常规目录。 The two commands delete symbolic link from directory because it's considered as a file so, when using the rm or unlink command to remove a symbolic link from a directory, make sure you don't end the target with a / character because that will create an error这两个命令从目录中删除符号链接,因为它被视为一个文件,因此,当使用 rm 或 unlink 命令从目录中删除符号链接时,请确保不要以 / 字符结束目标,因为这将创建一个错误

Please read more in documentation , man pages etc.请在文档、手册页等中阅读更多内容。

As I understood question - you should remove symlink to directory, but make symlink for each file in directory to target directory.正如我理解的问题 - 你应该删除到目录的符号链接,但是为目录中的每个文件创建符号链接到目标目录。 So you will have two normal directories and lot of symlink for files.因此,您将有两个普通目录和大量文件符号链接。

Only this way you can delete one particular file in target directory and still have it in original directory只有这样,您才能删除目标目录中的一个特定文件,并且仍将其保留在原始目录中

If you want to make it work both ways - to delete file in original directory and still have it in target - make non symlink but hard link with ln for each file.如果您想让它以两种方式工作 - 删除原始目录中的文件并将其保留在目标中 - 为每个文件制作非符号链接但与 ln 硬链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 删除原始文件夹后删除符号链接 - Delete a symbolic link when the original folder is deleted Linux:如果删除了快捷方式/链接,如何删除原始文件 - Linux: How to delete the original file if the shortcut/link is deleted 如何将符号链接文件从Linux复制到Windows,然后再复制到Linux,但仍将其保留为符号链接 - How to copy symbolic link file from Linux to Windows and then back to Linux but still keeping it as a symbolic link Linux:使用另一个文件夹中的符号链接执行时找不到bin文件 - Linux: bin file not found when executed using a symbolic link in another folder 如何检测何时在Linux中的符号链接目录中修改了一个文件 - How to detect when one file is modified inside a symbolic link directory in Linux 使用 Linux 加载程序时出现 ldconfig 错误:“不是符号链接” - ldconfig error:"is not a symbolic link" when using Linux loader 如何确定linux符号链接是否指向目录或文件 - How to determine if a linux symbolic link points to a directory or a file 如何为linux web服务器创建符号链接 - How to create Symbolic link for linux web server 如何防止 Linux 符号链接断开 - How to prevent Linux symbolic link from breaking Linux如何复制符号链接并保留日期 - Linux How to copy symbolic link and preserve date
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM