||AerieBSD 1.0 Refernce Manual
make hard and symbolic links to files
utility creates a new directory entry (linked file) which has the
same modes as the original file.
It is useful for maintaining multiple copies of a file in many places
at once without using up storage for the copies;
instead, a link
to the original copy.
There are two types of links; hard links and symbolic links.
How a link points
to a file is one of the differences between a hard and symbolic link.
The options are as follows:
A hard link to a file is indistinguishable from the original directory entry;
any changes to a file are effectively independent of the name used to reference
Hard links may not normally refer to directories and may not span file systems.
A symbolic link contains the name of the file to
which it is linked.
The referenced file is used when an
operation is performed on the link.
on a symbolic link will return the linked-to file; an
must be done to obtain information about the link.
call may be used to read the contents of a symbolic link.
Symbolic links may span file systems, refer to directories, and refer to
Given one or two arguments,
creates a link to an existing file
is given, the link has that name;
may also be a directory in which to place the link.
Otherwise, it is placed in the current directory.
If only the directory is specified, the link will be made
to the last component of
Given more than two arguments,
makes links in
to all the named source files.
The links made will have the same name as the files being linked to.
utility exits 0 on success or >0 if an error occurred.
Unlink any already existing file, permitting the link to occur.
If the target is a symlink to a directory, do not descend into it.
An alias for
for compatibility with other operating systems.
Create a symbolic link.
Create a symbolic link named
and point it to
# ln -s /var/www /home/www
# ln /usr/local/bin/fooprog-1.0 /usr/local/bin/fooprog
As an exercise, try the following commands:
$ ls -i /bin/[
$ ls -i /bin/test
Note that both files have the same inode; that is,
is essentially an alias for the
This hard link exists so
may be invoked from shell scripts, for example, using the
"if [ ]"
In the next example, the second call to
removes the original
and creates a replacement pointing to
$ mkdir bar baz
$ ln -s bar foo
$ ln -shf baz foo
option, this would instead leave
create a new symlink
pointing to itself.
This results from directory-walking.
utility is compliant with the
are extensions to that specification.
utility appeared in
Version 3 AT&T UNIX.
file must have its link count incremented, a hard link cannot be created to a
file which is flagged immutable or append-only (see
| AerieBSD 1.0 Reference Manual
|| August 26 2008