ln command
Create hard and symbolic links.
- Files & directories
- Package coreutils
- 5 options · 5 examples
Syntax
ln [options] target link_nameProvided by the coreutils package. Run man ln for the full manual.
Common options
| Option | What it does |
|---|---|
-s | Create a symbolic link |
-f | Replace the link if it exists |
-n | Treat a link to a directory as a file (with -f) |
-v | Print each link made |
-r | Make the link relative |
Examples
Create a symbolic link
ln -s /opt/app/current/bin/app /usr/local/bin/appEnable an Nginx site
sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/Replace an existing link
ln -sfn /opt/app/releases/v2 /opt/app/currentCreate a hard link
ln file.txt file-hardlink.txtSee where a link points
readlink -f /usr/bin/python3
No example matches. Check the options table or search the guides.
ln guides
- How To Create and Manage Symbolic Links in Linux Linux Commands · Updated Apr 2025
