Ln (Unix)

From Free net encyclopedia

Template:Lowercase

The ln command is used on Unix-like systems to create links between files. Links allow more than one location to refer to the same information.

There are two types of links, both of which are created by ln:

  • Symbolic links, which refer to a symbolic path indicating the abstract location of another file, and
  • Hard links, which refer to the specific location of physical data.

Contents

Usage

The general syntax for the ln command is:

ln [-s] target [name]

The target parameter indicates the location or file to which the link should point. The optional name parameter specifies the name that link should be given. If no name is specified, the basename of the target will be used. The ln utility creates a hard link by default; the -s option indicates that a symbolic link should be created instead.

Examples

ln xyz abc

Creates a hard link called abc that points to the same data as the existing file xyz.

ln -s /usr/share/pixmaps/image.jpg

Creates a symbolic link that points to the path /usr/share/pixmaps/image.jpg. The link would be named image.jpg, because that is the basename of its target.

ln harder dir/hard

Links dir/hard --> ./harder but

ln -s softer dir/soft

links dir/soft --> dir/softer which is probably unintended.

See also

External links