Skip to content

Files and finding

8 min

A name is not a file

Hard links, and what rm actually removes.

A file is an inode: some bytes, a mode, an owner, a link count. A name is an entry in a directory that points at one. They are different things, and a file can have more than one name.

ln makes a second name. ls -li shows the inode number both names share, and the link count going to 2.

Try this

Watch the LINKS column in the files pane. It is 2 for both names, because there is only one file.

rm removes a name, not a file. The inode survives as long as any name still points at it, which is why removing one of two links loses nothing.

A symbolic link is a different thing entirely: a small file whose contents are a path. It can point at something that does not exist, and it breaks when the target moves.

Try this

$

Files

The files in the sandbox, with their modes, link counts and sizes
ModeLinksSizeName
-rw-r--r--165budget.txt
-rw-r--r--1100draft.txt
-rw-r--r--1134receipt.md