I have a directory like this:
$ ls -l
total 899166
drwxr-xr-x 12 me scicomp 324 Jan 24 13:47 data
-rw-r--r-- 1 me scicomp 84188 Jan 24 13:47 lod-thin-1.000000-0.010000-0.030000.rda
drwxr-xr-x 2 me scicomp 808 Jan 24 13:47 log
lrwxrwxrwx 1 me scicomp 17 Jan 25 09:41 msg -> /home/me/msg
And I want to remove it using rm -r
.
However I'm scared rm -r
will follow the symlink and delete everything in that directory (which is very bad).
I can't find anything about this in the man pages. What would be the exact behavior of running rm -rf
from a directory above this one?
Best Answer
Example 1: Deleting a directory containing a soft link to another directory.
So, we see that the target of the soft-link survives.
Example 2: Deleting a soft link to a directory
Only, the soft link is deleted. The target of the soft-link survives.
Example 3: Attempting to delete the target of a soft-link
The file in the target of the symbolic link does not survive.
The above experiments were done on a Debian GNU/Linux 9.0 (stretch) system.