Skip to main content

Command referenceln

ln command (Linux / bash / sh / zsh)

Linuxbashshzshfileintermediate

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 / optionMeaning
-sCreate a symbolic link.
-fReplace an existing destination.
-nTreat a destination symlink as a normal file.
-vReport 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.

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.