软链接该如何删除?
先创建测试用的目录和文件:
# cd /tmp # mkdir test1 # touch test1/{1,2,3}.txt # ln -s /tmp/test1/ /tmp/test2 # ls -l drwxr-xr-x 2 root root 4096 Sep 4 16:09 test1 lrwxrwxrwx 1 root root 11 Sep 4 16:10 test2 -> /tmp/test1/
错误做法:
# rm -rf test2/ # ls -l drwxr-xr-x 2 root root 4096 Sep 4 16:15 test1 lrwxrwxrwx 1 root root 11 Sep 4 16:10 test2 -> /tmp/test1/ # ls test1/
软链接还在,原目录下的文件却不在了……
正确的步骤:
再创建3个txt文件: # touch test1/{1,2,3}.txt 删除软链接: # rm -rf test2 # ls test1
转载于:https://blog.51cto.com/13568014/2170201