add POSIX/IEEE contribution notice
[unix-history] / usr / src / bin / ln / ln.1
CommitLineData
d9d7a9f0
CL
1.\" Copyright (c) 1980, 1990 The Regents of the University of California.
2.\" All rights reserved.
8b99182b 3.\"
cf136d2c
KB
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
d9d7a9f0 7.\" %sccs.include.redist.man%
8b99182b 8.\"
cf136d2c 9.\" @(#)ln.1 6.7 (Berkeley) %G%
d9d7a9f0 10.\"
ee9b0a0a 11.Vx
d9d7a9f0
CL
12.Dd
13.Dt LN 1
14.Os BSD 4
15.Sh NAME
16.Nm ln
17.Nd make links
18.Sh SYNOPSIS
19.Nm ln
5325ced3
CL
20.Op Fl s
21.Ar source_file
22.Op target_file
d9d7a9f0
CL
23.Nm ln
24.Op Fl s
5325ced3
CL
25.Ar source_file ...
26.Op target_dir
d9d7a9f0
CL
27.Sh DESCRIPTION
28The
29.Nm ln
30utility creates a new
5325ced3
CL
31directory entry (linked file)
32which inherits the same modes as the orginal
33file.
34It is useful for maintaining multiple copies of a file in
35many places at once - without the `copies'; instead,
36a link `points' to the original copy.
37There are two types of links; hard links and symbolic links.
38How a link `points' to a file is one of the differences
39between a hard or symbolic link.
40.Pp
41Option available:
42.Tw Ds
43.Tp Fl s
44Create a symbolic link.
45.Tp
d9d7a9f0 46.Pp
da202ae8 47By default
d9d7a9f0
CL
48.Nm ln
49makes
50.Em hard
51links.
da202ae8
KM
52A hard link to a file is indistinguishable from the
53original directory entry; any changes to a
54file are effective independent of the name used
7529dd22
KB
55to reference the file. Hard links may not refer to directories
56(unless the proper incantations are supplied) and may not span
57file systems.
d9d7a9f0 58.Pp
da202ae8
KM
59A symbolic link contains the name of the file to
60which it is linked. The referenced file is used when an
d9d7a9f0 61.Xr open 2
da202ae8
KM
62operation is performed on the link.
63A
d9d7a9f0 64.Xr stat 2
da202ae8 65on a symbolic link will return the linked-to file; an
d9d7a9f0 66.Xr lstat 2
da202ae8
KM
67must be done to obtain information about the link.
68The
d9d7a9f0 69.Xr readlink 2
da202ae8
KM
70call may be used to read the contents of a symbolic link.
71Symbolic links may span file systems and may refer to directories.
d9d7a9f0 72.Pp
8b99182b 73Given one or two arguments,
d9d7a9f0 74.Nm ln
8b99182b 75creates a link to an existing file
d9d7a9f0 76.Ar source_file .
8b99182b 77If
d9d7a9f0 78.Ar target_file
8b99182b 79is given, the link has that name;
d9d7a9f0 80.Ar target_file
8b99182b
KM
81may also be a directory in which to place the link;
82otherwise it is placed in the current directory.
da202ae8
KM
83If only the directory is specified, the link will be made
84to the last component of
d9d7a9f0
CL
85.Ar source_file .
86.Pp
8b99182b 87Given more than two arguments,
d9d7a9f0
CL
88.Nm ln
89makes links in
90.Ar target_dir
9f0d4865 91to all the named source files.
8b99182b 92The links made will have the same name as the files being linked to.
d9d7a9f0
CL
93.Sh SEE ALSO
94.Xr rm 1 ,
95.Xr cp 1 ,
96.Xr mv 1 ,
97.Xr link 2 ,
98.Xr readlink 2 ,
99.Xr stat 2 ,
100.Xr symlink 2
101.Sh HISTORY
102A
103.Nm ln
104command appeared in Version 6 AT&T Unix.