21

This is the contents of the /home3 directory on my system:

./   backup/    hearsttr@  lost+found/  randomvi@  sexsmovi@
../  freemark@  investgr@  nudenude@    romanced@  wallpape@

I want to clean this up but I am worried because of the symlinks, which point to another drive.

If I say rm -rf /home3 will it delete the other drive?

1 Answer 1

32

rm -rf /home3 will delete all files and directory within home3 and home3 itself, which include symlink files, but will not "follow"(de-reference) those symlink.

Put it in another words, those symlink-files will be deleted. The files they "point"/"link" to will not be touch.

4
  • 1
    Note that this is true for rm -rf /home3, but not for rm -rf /home3/. The latter will remove the target directory and its contents, but will keep the link.
    – FWDekker
    Commented Jan 13, 2023 at 18:15
  • 2
    @FWDekker There is no difference with or without the ending /. home3 is a directory and both its content and itself will be deleted.
    – John Siu
    Commented Apr 6, 2023 at 16:59
  • 5
    My bad, you're right, I think I misread the question when I commented that. My comment applies to the case where /home3 itself is a symlink: rm -rf /home3 would only remove the link, but rm -rf /home3/ would erase all files in the directory that is linked to.
    – FWDekker
    Commented Apr 7, 2023 at 9:47
  • 2
    @FWDekker If home3 is symlink, then you are right.
    – John Siu
    Commented Apr 10, 2023 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .