ln

create a link to a file

Command


SYNOPSIS

ln [-fiRrv] old new

ln [-fiRrsv] old old ... dir


DESCRIPTION

ln creates a link to a file or set of files. A link is a new directory entry that refers to the same file, either in the directory that currently contains the file or in a different directory. The result is a new path name that refers to the file. You can access the file under the old path name or the new one; both path names are of equal importance. If you rm either name, the other one remains and the file contents are still available under that name. The contents of the file do not disappear until you remove the last link.

A file may have any number of links to it. Thus you can establish any number of different path names for any file.

In the first form given in the synopsis, new becomes a new path name for the file old. In the second form, ln creates entries for all the old files under the directory dir. For example,
ln yourdir/* mydir
creates links under mydir to all the files under yourdir. The files have the same names under mydir that they had under yourdir. ln always assumes this directory form when the last operand on the command line is the name of a directory. In this case, none of the old names may be a directory.

In some cases a file may have the same name as the link you are trying to set up. This file is referred to as the conflicting path name. To deal with a conflicting path name, ln follows these steps.

Options

-f

removes conflicting path names without asking for confirmation.

-i

checks with you before getting rid of conflicting path names. (Note that the -f option overrides the -i option.)

-R

links files recursively; that is, you can link an entire hierarchy of subdirectories at once.

-r

is identical to -R.

-s

creates a symbolic link.

-v

shows file names as they are processed.


DIAGNOSTICS

Possible exit status values are:
0

All requested links were established successfully.

1

Failure due to any of the following:

— an argument had a trailing / but was not the name of a directory
— a file could not be found
— an input file could not be opened for reading
— an output file could not be created or opened for output
— the new link file already exists
— a link could not be established
— a read error occurred on an input file
— a write error occurred on an output file
— the input and output files were the same file
— inability to access a file when using -r
— inability to read a directory when using -r
— inability to create a directory when using -r
— a target is not a directory when using -r
— source and destination directory are the same when using -r
2

Failure due to any of the following:

— invalid command line option
— too few arguments on the command line
— a target that should be a directory but isn't
— no space left on target device
— out of memory to hold the data to be copied
— unable to create a directory to hold a target file


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0.

Only the -f option is part of the POSIX standard.


SEE ALSO

Commands:
cp, mv, rm


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]