Skip to main content
1 of 9
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k
$ touch name
$ ln name othername
$ ls -l
total 0
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 name
-rw-r--r--  2 kk  wheel  0 Sep 10 09:29 othername
$ rm othername
$ ls -l
total 0
-rw-r--r--  1 kk  wheel  0 Sep 10 09:29 name

You're doing something seriously wrong if, by removing one hard link, you also remove the other. Using rm or rm -rf in this case does not matter.

Removing a hard link just removes one of the names of the file. The only way I can see that rm -rf could remove both names is if you used it with a filename glob that matched both names, or if you deleted the directory that contained them both.

Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k