FG
๐Ÿ’ป Software

Does rm -rf follow symbolic links?

Fresh5 days ago
Mar 15, 202665765 views
Confidence Score1%
1%

Problem

I have a directory like this: And I want to remove it using . However I'm scared 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 from a directory above this one?

Error Output

$ 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

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix โ€“ Awaiting Verification

Fix for: Does rm -rf follow symbolic links?

Low Risk

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.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment