Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a symbolic link with ln -s TARGET LINK_NAME. Put the existing or intended target path first and the new link name second:

ln -s /srv/data/report.csv report-link.csv

This creates report-link.csv in the current directory, pointing to /srv/data/report.csv. A symbolic link stores a path to its target; it does not copy the target file.

What the command’s arguments mean

The -s option tells ln to create a symbolic link. With two path operands, the first is the target and the second is the name of the new link. GNU Coreutils documents this form in its ln invocation manual.

ln -s TARGET LINK_NAME

For example, run this command from the directory where you want the link to appear:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ln -s /srv/data/report.csv report-link.csv

The target may be a file or directory. A symbolic link can also be created before its target exists, so a successful command does not by itself prove the link points to a working path.

Choose an absolute or relative target

An absolute target begins at the filesystem root, /. A relative target is resolved from the directory containing the link—not from the shell’s working directory at the time someone later follows it. For example, if /home/lee/links/report stores ../data/report.csv, that path resolves from /home/lee/links to /home/lee/data/report.csv. The GNU manual explains how relative link targets are interpreted; the Linux manual page also describes the path string stored by a symbolic link (symlink(7)).

Target style Useful when Trade-off
Absolute The link should name the same target path even if the directory containing the link moves. It may not resolve on another machine if a shared filesystem is mounted under a different path.
Relative The link and target are part of a directory tree that may move together, or machines use different mount-point names. The relative directory layout must stay intact; moving only the link or target can break resolution.

When making a relative link, run ln -s from the directory where the link will live, or calculate the target path relative to that directory. Reusing the same relative string from a different location can point somewhere else.

Handle an existing destination safely

GNU ln normally refuses to replace an existing destination. Check what is already there before choosing an overwrite option:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ls -l LINK_NAME

GNU Coreutils provides these alternatives:

  • -i prompts before replacing a destination.
  • -b makes a backup of an existing destination.
  • -f removes an existing destination unconditionally before creating the link.

Use -f only when you have confirmed that removing the destination is safe. These option details describe GNU Coreutils; check the local ln manual on other Unix-like systems.

Link into a directory or use a directory as the link name

If the final operand is a directory, GNU ln normally creates the link inside that directory. To make the final operand the exact link name even when it is a directory, GNU ln provides -T. Its -n option changes how a final operand that is a symbolic link to a directory is treated; the GNU manual notes that -T takes precedence when both options are used. These are GNU-specific conveniences, so verify availability before relying on them outside GNU Coreutils.

Verify the link and check for a missing target

Use ls -l to see the link and its displayed target, and readlink to print the path string stored in the link:

ls -l LINK_NAME
readlink LINK_NAME

For a relative target, do the check with the link in its actual directory: the stored path is interpreted from there. A symbolic link may point to a path that is currently absent (a dangling link), so also confirm that the target resolves if you need a working file or directory path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

GNU options and portability

The basic ln -s TARGET LINK_NAME form is the essential command for creating a symbolic link on Linux. GNU Coreutils also offers -r (or --relative) to generate a relative link, and -T to stop treating the final directory operand specially. The available options can differ on other Unix-like systems; consult the local ln manual before using GNU-specific flags.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.