Where to start First steps track · 15 stages
Linux Labs

ln — symbolic and hard links

cheat sheet · GNU coreutils https://lab.dimsanych.ru/en/wiki/ln/

Cheat sheet

  • ln -s /opt/app/current/bin/app /usr/local/bin/app symlink (order like cp)
  • ln -sf /new/target link recreate it
  • readlink -f link the real path
  • ln file hardname a hard link
  • find . -xtype l find broken symlinks

Options

-s is the one option that makes a symlink instead of a hard link; without it ln creates a hard link. -f overwrites an existing link name — without confirmation, so it's risky with someone else's or important files. -n matters specifically when replacing a symlink that points to a directory: without it, ln -sf target dir drops the new link inside dir instead of replacing dir itself.

Loading…