ln command (Linux / bash / sh / zsh)
What it does
Create hard links or symbolic links to filesystem entries. When people search for the ln command linux symbolic link, they usually want ln's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Create hard links or symbolic links to filesystem entries.
Syntax
ln [OPTION]... TARGET [LINK_NAME]
Common options
| Flag / option | Meaning |
|---|---|
| -s | Create a symbolic link. |
| -f | Replace an existing destination. |
| -n | Treat a destination symlink as a normal file. |
| -v | Report each created link. |
Practical examples
Symbolic link
ln -s /opt/app/current app-current
Creates a symlink to the deployed app.
Relative link
ln -s ../shared/config.yml config.yml
Creates a portable relative symlink.
Hard link
ln report.txt report-copy.txt
Creates another name for the same inode.
Common mistakes
- Reversing target and link name.
- Creating an absolute symlink that breaks when a directory tree is moved.
Related commands
- lsList directory entries and inspect file metadata.
- cpCopy files or directory trees to another location.
- findWalk directory trees and select entries using tests and actions.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- cdDisplay or change the current directory in Command Prompt.
- rmRemove files and directory trees permanently.
FAQ
What does ln do in Linux?
Create hard links or symbolic links to filesystem entries.
How do I use ln from the terminal?
Start with `ln [OPTION]... TARGET [LINK_NAME]`, then choose only the options needed for the task.
What is a practical ln example?
Try `ln -s /opt/app/current app-current` — Creates a symlink to the deployed app.
Can I use ln in a shell script?
Yes. ln works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.