Pcornel
Linux · Filesystem

Symbolic Links

Cheat sheet · https://pcornel.dk/topic.php?topic=2676

Back to the Topic

Answer

A symbolic (soft) link is a small file that contains a path to another file or directory (ln -s target link). It can cross filesystems and point to directories, but breaks if the target moves.

Remember

Relative targets are resolved from the link's directory, not your current directory. ls -l shows the target; readlink -f the final resolved path. Permissions of the link itself do not matter — the target's do.

First checks

  • readlink -f <link> — resolved target
  • find <dir> -xtype l — broken symbolic links
  • ls -ld <path> — owner, permissions and type
  • stat <path> — inode, links, size and timestamps
  • df -h <path> — filesystem and free space
  • findmnt <path> — which mount the path is on

Verify in this order

link opened → kernel reads the stored path → resolves it (relative to the link's directory) → opens the target

Where it usually breaks

First mismatch in hardware/block device → kernel driver/mapper/RAID/LVM → filesystem → mount namespace/options → path permissions/MAC → consumer I/O; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2676

Confirmation

Confirm action

Continue?