manual page distributed with 4.2BSD
[unix-history] / usr / src / bin / ln / ln.1
CommitLineData
8b99182b
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
da202ae8 5.\" @(#)ln.1 5.1 (Berkeley) %G%
8b99182b 6.\"
da202ae8 7.TH LN 1 "17 March 1982"
8b99182b
KM
8.UC 4
9.SH NAME
10ln \- make links
11.SH SYNOPSIS
12.B ln
da202ae8
KM
13[
14.B \-s
15]
8b99182b
KM
16name1 [ name2 ]
17.br
18.B ln
19name ... directory
20.SH DESCRIPTION
21A link is a directory entry referring
22to a file; the same file (together with
23its size, all its protection
24information, etc.)
25may have several links to it.
da202ae8
KM
26There are two kinds of links: hard links and symbolic links.
27.PP
28By default
29.I ln
30makes hard links.
31A hard link to a file is indistinguishable from the
32original directory entry; any changes to a
33file are effective independent of the name used
34to reference the file.
35Hard links may not span file systems and may not refer to directories.
36.PP
37The
38.B \-s
39option causes
40.I ln
41to create symbolic links.
42A symbolic link contains the name of the file to
43which it is linked. The referenced file is used when an
44.IR open (2)
45operation is performed on the link.
46A
47.IR stat (2)
48on a symbolic link will return the linked-to file; an
49.IR lstat (2)
50must be done to obtain information about the link.
51The
52.IR readlink (2)
53call may be used to read the contents of a symbolic link.
54Symbolic links may span file systems and may refer to directories.
8b99182b
KM
55.PP
56Given one or two arguments,
57.I ln
58creates a link to an existing file
59.IR name1 .
60If
61.I name2
62is given, the link has that name;
63.I name2
64may also be a directory in which to place the link;
65otherwise it is placed in the current directory.
da202ae8
KM
66If only the directory is specified, the link will be made
67to the last component of
8b99182b
KM
68.IR name1 .
69.PP
70Given more than two arguments,
71.I ln
72makes links to all the named files in the named directory.
73The links made will have the same name as the files being linked to.
8b99182b 74.SH "SEE ALSO"
da202ae8 75rm(1), cp(1), mv(1), link(2), readlink(2), stat(2), symlink(2)