linux - linux使用符号链接(symbolic link)时如何使原文件不被删除

标签 linux file directory symlink

我想问当我删除文件夹符号链接(symbolic link)目标中的文件时,是否可以使该文件在原始文件中仍然可用? 我使用 ls -n/folder/target 但当我删除 /target 中的文件时,原始文件夹中的文件也被删除。

最佳答案

使用 rm 删除符号链接(symbolic link)

rm symlink_name

使用unlink删除符号链接(symbolic link)

unlink symlink_name

Unlink command and rm command without -R option doesn't delete regular directory. 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

更多内容请阅读documentation 、手册页等

关于linux - linux使用符号链接(symbolic link)时如何使原文件不被删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61054770/

相关文章:

android - 从 GridView 中的特定 SDCard 文件夹加载图像

svn - 如何找出我的工作副本来自哪个版本控制系统?

linux - 在Vim中编辑Go源文件时如何禁用空格突出显示?

linux - Bash 脚本 : continually modifying IP addresses in configuration file

c++ - Ifstream 读取奇怪的行为

java - 数组列表和文件

java - 创建目录。如果存在,删除目录及其内容并在 Java 中创建新目录

linux - 当他们在这种情况下说 "fragile state"时,它实际上是什么意思?

java - maven war 应用程序设置 contextroot

c - 用C语言读写多行数据文件