daveg
daveg

Reputation: 1211

recursive rm -rf of a symlink ?

I think I know the answer to this one but I'll ask anyway.

I created a symlink to a dir on a different disk. A script (which I have no control over) will "rm -rf *" in the dir that has this symlink. It deletes the symlink OK, but leaves the target dir on the other directory. I expected this but want to make sure that there's no way I can create the symlink somehow to behave like a hard link in terms of making "rm -rf " recursively delete the dir on the other disk. -T looked kind of promising, but didn't pan out. Again, I have no control over the rm command execution. But I do create the target dir on the other disk, plus I create the symlink to it..

Thanks in advance!

Upvotes: 2

Views: 2402

Answers (1)

bclarkreston
bclarkreston

Reputation: 637

What you are essentially asking is can a hard link be created across file systems. The answer is, they cannot. This tutorial confirms this:

An important thing to note about hard links is that they only work on the current file system. You can not create a hard link to a file on a different file system. To do that you need to use symbolic links, Section 1.4.3.

As you seem to already understand, removing a softlink will have no effect on the the thing it is linked to. This is true for hardlinks as well.

Upvotes: 2

Related Questions