LinuxCommandLibrary

ln

TLDR

Create symbolic link

$ ln -s [target] [linkname]
copy
Create hard link
$ ln [target] [linkname]
copy
Create symbolic link (force overwrite)
$ ln -sf [target] [linkname]
copy
Create link in directory
$ ln -s [target] [directory/]
copy
Create relative symbolic link
$ ln -sr [target] [linkname]
copy
Verbose output
$ ln -sv [target] [linkname]
copy

SYNOPSIS

ln [options] target linkname

DESCRIPTION

ln creates links between files. Hard links share the same inode; symbolic links are references.
Symbolic links can span filesystems and link to directories. Hard links cannot.
ln creates file links.

PARAMETERS

TARGET

File or directory to link to.
LINKNAME
Name for the link.
-s
Create symbolic (soft) link.
-f
Force, overwrite existing.
-r
Create relative symbolic link.
-v
Verbose output.
-n
Don't dereference symlinks.
--help
Display help information.

CAVEATS

Hard links cannot cross filesystems. Symbolic links can break if target moves. Directory hard links not allowed.

HISTORY

ln is a traditional Unix command dating back to the original Unix system for creating links between files.

SEE ALSO

link(1), unlink(1), readlink(1), symlink(7)

Copied to clipboard