ln

Official Description

Makes a hard link or a symbolic link to a file.

Syntax

ln [-fs] sourcename [targetname]

Options

-f forces the removal of the existing target pathnames.

-s creates symbolic links. Symbolic links are sometimes referred to as soft links.

-n can be included to prevent the creation of the link if the target already exists.

Oddities

Hard links will not work beyond file system boundaries, nor will they work for directories.

Example

$ ln -s buzz ln_buzz         # Make symbolic link to buzz
$
$ ls -l ln_buzz
lrwxrwxrwx   1 obrien   obrien          4 Nov 27 08:24 ln_buzz -> buzz
$
$ ls -lL ln_buzz
-r-x-w-r-x   1 obrien   obrien         47 Nov 26 12:19 ln_buzz
$
$ cat ln_buzz                # Use symbolic link
#! /bin/ksh
integer x=17
while :
do
x=17
done
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.