Files & folders

Linux ln command

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

Availability: Common Linux commands; shell built-ins and external implementations may differ by distribution.中文

Syntax

ln [OPTION]... TARGET [LINK_NAME]

Examples

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

Parameters, options and clauses

Option / clauseDescription
-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.
Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory