Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux ln command

Create a link. Use -s to create a symbolic link.

GNU Coreutils

Syntax

Command form
ln [OPTION]... TARGET [LINK_NAME]

Common options

6 options
OptionWhat it does
-s, --symbolicCreate a symbolic link instead of a hard link.
-f, --forceRemove an existing destination link before creating the new one.
-i, --interactivePrompt before removing an existing destination.
-n, --no-dereferenceTreat a destination symlink to a directory as a normal file.
-T, --no-target-directoryAlways treat LINK_NAME as the link name, not a directory.
-v, --verbosePrint the name of each created link.

Usage examples

3 examples

Create a link. Use -s to create a symbolic link.

ln -s /opt/app ./app

Create a symbolic link to a log file.

ln -s /var/log/app.log app.log

Create a hard link on the same filesystem.

ln source.dat source-hardlink.dat

Notes

Symbolic links can cross filesystems and may point to missing targets; hard links generally cannot cross filesystem boundaries.