terminal.cab

All commands

ln

Topic: Files and folders

Program: ln

Creates hard or symbolic links.

Package: core-inodes

Usage

ln [OPTION]... TARGET... [LINK_NAME|DIRECTORY]

Description

Give TARGET a second name LINK_NAME (a hard link), or with -s a symlink that stores the path TARGET. Without LINK_NAME the link is made in the current directory; with a DIRECTORY at the end, inside it.

Options in the simulator

10 more options of the real program, not in the simulator yet
  • --backup value optional not in the simulator yet

    On a real system ln first keeps a name it replaces as a backup copy ending in ~.

  • -b not in the simulator yet

    On a real system ln first keeps a name it replaces as a backup copy ending in ~.

  • -d, --directory not in the simulator yet

    On a real system root may try a hard link to a directory with it; the file system almost always refuses.

  • -F not in the simulator yet

    On a real system root may try a hard link to a directory with it; the file system almost always refuses.

  • -i, --interactive not in the simulator yet

    On a real system ln asks before it replaces a name that already exists.

  • -L, --logical not in the simulator yet

    On a real system it decides whether a hard link to a symlink gets the link itself or its target.

  • -P, --physical not in the simulator yet

    On a real system it decides whether a hard link to a symlink gets the link itself or its target.

  • -S, --suffix needs a value not in the simulator yet

    On a real system it picks the ending of the backup copy instead of ~.

  • -t, --target-directory needs a value not in the simulator yet

    On a real system it names the directory for the new links before the sources.

  • --version not in the simulator yet

    On a real system it prints the version of the program.

Examples

From the lesson Delete, link, measure
ln -s projects/shop/releases/v2.4.1 current
ls -l current
lrwxrwxrwx 1 lerner lerner 29 Oct 17 09:42 current -> projects/shop/releases/v2.4.1
cat current/VERSION
2.4.1
ln notes.txt second.txt
stat -c '%h links, inode %i: %n' notes.txt second.txt
2 links, inode 78: notes.txt
2 links, inode 78: second.txt

Try it in the terminal

Where you learn it

Lessons

All commands