filename linknameTo create a hard link %
filename linknameTo create a symbolic link
In either case,
filename must already exist. Otherwise you
will get an error message.
If you are using Berkeley UNIX,
linkname must not exist - if it does, you will get an error.
Under System V,
linkname may already exist; if you are
allowed to write the file, ln destroys its old contents and
creates your link.
If you don't have write access for
linkname, ln asks whether or not it is OK to override the
ln foo barln: override protection 444 for bar?
y gives ln permission to destroy the file bar and create
Note that this will still fail if you don't have write
access to the directory.
You are allowed to omit the
linkname argument from the ln
In this case, ln takes the last component of
filename (i.e., everything after the last slash) and uses it
Of course, this assumes that
refer to the current directory.
If it does, the command will fail:
the link will already exist.
For example, the commands below are the same:
Both create a link from file.c in the current directory to ../archive/file.c.
ln also lets you create a group of links with one command, provided that all of the links are in the same directory. Here's how:
file1 file2 file3 ... filen directory
This command uses the filename from each pathname
(after the last slash) as each link's name. It
then creates all the links within the given
For example, the first command below is equivalent to the next two:
ln ../s/f1 ../s/f2 current%
ln ../s/f1 current/f1%
ln ../s/f2 current/f2
You can replace this list of files with a, as in:
Note that symbolic links can . [Hard links can also be "broken" in some situations. For example, a text editor might rename the link textfile to textfile.bak, then create a new textfile during editing. Previous links to textfile will now give you textfile.bak. To track down this problem, to each file. -JP ]