LINUX / A CONCEPT NOTE

Symlinks & Hard Links

two names for one file

~65 sec read

Overview · mechanism
pitfall · examples

01 / THE SHORT VERSION

The idea in a few sentences.

A symlink is a pointer file referencing another file path (like a shortcut). A hard link is a duplicate directory entry pointing directly to the file's raw disk sectors (inode).

02 / FOLLOW THE MECHANISM

How symlinks vs hard links behave

  1. Symlink read

    OS opens symlink, reads the path target string, and redirects to target file.

  2. Hard link read

    OS maps hard link directory entry directly to the file's raw disk partition inode.

  3. Target deleted

    if target is deleted, symlink breaks immediately, but hard link still opens the data.

  4. Link limits

    hard links cannot span different filesystems or reference directories.

04 / COMMAND NOTES

Read the command, then the result.

Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.

EXAMPLE 01 · REFERENCE

create a symbolic link

ln -s target.txt shortcut.txt

EXAMPLE 02 · REFERENCE

create a hard link

ln target.txt hardlink.txt

Explore command anatomy in the CLI lab