xref: /original-bsd/bin/ln/ln.1 (revision 76210d32)
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.4 (Berkeley) 06/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 Ar source_file
17.Op  target_file
18.Nm ln
19.Op Fl s
20.Ar source_file ... target_dir
21.Sh DESCRIPTION
22The
23.Nm ln
24utility creates a new
25directory entry (a link)
26for a file which
27inherits the same modes.
28The entry behaves in most cases as if it were the
29original file.
30It is useful for keeping groups of files together
31in directories, but with out multiple copies of the same file.
32There are two kinds of links: hard links and symbolic links.
33.Pp
34By default
35.Nm ln
36makes
37.Em hard
38links.
39A hard link to a file is indistinguishable from the
40original directory entry; any changes to a
41file are effective independent of the name used
42to reference the file.  Hard links may not refer to directories
43(unless the proper incantations are supplied) and may not span
44file systems.
45.Pp
46Options:
47.Tp Fl s
48Create symbolic links.
49A symbolic link contains the name of the file to
50which it is linked.  The referenced file is used when an
51.Xr open  2
52operation is performed on the link.
53A
54.Xr stat  2
55on a symbolic link will return the linked-to file; an
56.Xr lstat  2
57must be done to obtain information about the link.
58The
59.Xr readlink  2
60call may be used to read the contents of a symbolic link.
61Symbolic links may span file systems and may refer to directories.
62.Tp
63.Pp
64Given one or two arguments,
65.Nm ln
66creates a link to an existing file
67.Ar source_file  .
68If
69.Ar target_file
70is given, the link has that name;
71.Ar target_file
72may also be a directory in which to place the link;
73otherwise it is placed in the current directory.
74If only the directory is specified, the link will be made
75to the last component of
76.Ar source_file  .
77.Pp
78Given more than two arguments,
79.Nm ln
80makes links in
81.Ar target_dir
82to all the named source files.
83The links made will have the same name as the files being linked to.
84.Sh SEE ALSO
85.Xr rm 1 ,
86.Xr cp 1 ,
87.Xr mv 1 ,
88.Xr link 2 ,
89.Xr readlink 2 ,
90.Xr stat 2 ,
91.Xr symlink 2
92.Sh HISTORY
93A
94.Nm ln
95command appeared in Version 6 AT&T Unix.
96