Why Did `rm -rf` Not Remove My Symlinks?

0
7
Asked By CuriousCat88 On

I thought running `rm -rf NAS/folder/` would delete all files under that directory and remove any symlinks in linked folders while leaving the files in those linked folders untouched. However, I recently checked on a delete operation that started around 12 hours ago and noticed that it seems to have deleted some of my important Immich files. I had assumed it was safe to delete an older rsync copy from my old server since I hadn't used it in a while. The folder path was actually quite lengthy and I realized it started from something like `Home/server/snap/notepad-plus-plus/common/.wine/dosdevices/z:/usr/local/emhttp/mnt/NAS/Immich/guid/guid.jpg`. To be cautious next time, I'm planning to run `find . -type l -delete` to ensure all symlinks are cleared before attempting the delete again. The big question is, why didn't `rm -rf` remove the symlinks?

2 Answers

Answered By TechieTom24 On

That folder path you mentioned is a bit confusing. When asking about issues like this, every detail in the path is crucial. Regarding the `rm -rf` command, you’d expect it to remove symlinks, but it might depend on the filesystem it's dealing with and how you're connected to the NAS. Could you provide more details about the connection and file systems involved? Also, remember if you stopped the operation midway, the folders should still be there, so checking their status could help us understand more.

Answered By GordonP On

I've done a test that mirrors your setup and when using GNU `rm`, it behaves as expected by removing symlinks too. Can you confirm which version of `rm` you're using? If the NAS directory was mounted using a protocol like SMB that might not handle symlinks well, that could be part of the issue.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.