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