ln

Updated

July 31, 2026

Overview

ln creates hard links or symbolic links (symlinks). Symlinks are the usual tool for path aliases; hard links share inode data on the same filesystem.

Syntax

ln [options] target link_name
ln [options] target... directory

Common Options

Option Description
-s Symbolic link
-f Force replace
-n Treat link_name as normal file if symlink to dir
-v Verbose
-r Relative symlink (GNU)
-b Backup before overwrite

Examples with Explanations

Replace safely

ln -sfn /opt/app/releases/1.2 /opt/app/current

Notes

  • Hard links cannot cross filesystems or link directories (normally).
  • Broken symlinks show in ls (often red); test -e fails.
  • Prefer ln -s for version switches (current → release).