Skip to content

ln command

Create hard and symbolic links.

On this page

Syntax

ln [options] target link_name

Provided by the coreutils package. Run man ln for the full manual.

Common options

OptionWhat it does
-sCreate a symbolic link
-fReplace the link if it exists
-nTreat a link to a directory as a file (with -f)
-vPrint each link made
-rMake the link relative

Examples

  1. Create a symbolic link

    ln -s /opt/app/current/bin/app /usr/local/bin/app
  2. Enable an Nginx site

    sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/
  3. Replace an existing link

    ln -sfn /opt/app/releases/v2 /opt/app/current
  4. Create a hard link

    ln file.txt file-hardlink.txt
  5. See where a link points

    readlink -f /usr/bin/python3

ln guides

← All Linux commands · Suggest a fix

Back to top