Commit | Line | Data |
---|---|---|
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 | .\" | |
3d98c418 | 7 | .\" %sccs.include.redist.roff% |
8b99182b | 8 | .\" |
0d17b9a2 | 9 | .\" @(#)ln.1 6.14 (Berkeley) %G% |
d9d7a9f0 CL |
10 | .\" |
11 | .Dd | |
12 | .Dt LN 1 | |
13 | .Os BSD 4 | |
14 | .Sh NAME | |
15 | .Nm ln | |
16 | .Nd make links | |
17 | .Sh SYNOPSIS | |
18 | .Nm ln | |
022efdf4 | 19 | .Op Fl fs |
5325ced3 CL |
20 | .Ar source_file |
21 | .Op target_file | |
d9d7a9f0 | 22 | .Nm ln |
022efdf4 | 23 | .Op Fl fs |
5325ced3 CL |
24 | .Ar source_file ... |
25 | .Op target_dir | |
d9d7a9f0 CL |
26 | .Sh DESCRIPTION |
27 | The | |
28 | .Nm ln | |
022efdf4 EA |
29 | utility creates a new directory entry (linked file) which has the |
30 | same modes as the orginal file. | |
31 | It is useful for maintaining multiple copies of a file in many places | |
32 | at once without using up storage for the | |
33 | .Dq copies ; | |
34 | instead, a link | |
35 | .Dq points | |
36 | to the original copy. | |
5325ced3 | 37 | There are two types of links; hard links and symbolic links. |
022efdf4 EA |
38 | How a link |
39 | .Dq points | |
40 | to a file is one of the differences between a hard or symbolic link. | |
5325ced3 | 41 | .Pp |
022efdf4 | 42 | The options are as follows: |
3d98c418 | 43 | .Bl -tag -width flag |
022efdf4 EA |
44 | .It Fl f |
45 | Unlink any already existing file, permitting the link to occur. | |
3d98c418 | 46 | .It Fl s |
5325ced3 | 47 | Create a symbolic link. |
3d98c418 | 48 | .El |
d9d7a9f0 | 49 | .Pp |
da202ae8 | 50 | By default |
d9d7a9f0 CL |
51 | .Nm ln |
52 | makes | |
53 | .Em hard | |
54 | links. | |
022efdf4 EA |
55 | A hard link to a file is indistinguishable from the original directory entry; |
56 | any changes to a file are effective independent of the name used to reference | |
57 | the file. | |
58 | Hard links may not normally refer to directories and may not span file systems. | |
d9d7a9f0 | 59 | .Pp |
da202ae8 KM |
60 | A symbolic link contains the name of the file to |
61 | which it is linked. The referenced file is used when an | |
d9d7a9f0 | 62 | .Xr open 2 |
da202ae8 KM |
63 | operation is performed on the link. |
64 | A | |
d9d7a9f0 | 65 | .Xr stat 2 |
da202ae8 | 66 | on a symbolic link will return the linked-to file; an |
d9d7a9f0 | 67 | .Xr lstat 2 |
da202ae8 KM |
68 | must be done to obtain information about the link. |
69 | The | |
d9d7a9f0 | 70 | .Xr readlink 2 |
da202ae8 KM |
71 | call may be used to read the contents of a symbolic link. |
72 | Symbolic links may span file systems and may refer to directories. | |
d9d7a9f0 | 73 | .Pp |
8b99182b | 74 | Given one or two arguments, |
d9d7a9f0 | 75 | .Nm ln |
8b99182b | 76 | creates a link to an existing file |
d9d7a9f0 | 77 | .Ar source_file . |
8b99182b | 78 | If |
d9d7a9f0 | 79 | .Ar target_file |
8b99182b | 80 | is given, the link has that name; |
d9d7a9f0 | 81 | .Ar target_file |
8b99182b KM |
82 | may also be a directory in which to place the link; |
83 | otherwise it is placed in the current directory. | |
da202ae8 KM |
84 | If only the directory is specified, the link will be made |
85 | to the last component of | |
d9d7a9f0 CL |
86 | .Ar source_file . |
87 | .Pp | |
8b99182b | 88 | Given more than two arguments, |
d9d7a9f0 CL |
89 | .Nm ln |
90 | makes links in | |
91 | .Ar target_dir | |
9f0d4865 | 92 | to all the named source files. |
8b99182b | 93 | The links made will have the same name as the files being linked to. |
d9d7a9f0 | 94 | .Sh SEE ALSO |
d9d7a9f0 | 95 | .Xr link 2 , |
5a77d711 | 96 | .Xr lstat 2 , |
d9d7a9f0 CL |
97 | .Xr readlink 2 , |
98 | .Xr stat 2 , | |
0d17b9a2 KB |
99 | .Xr symlink 2 , |
100 | .Xr symlink 7 | |
d9d7a9f0 CL |
101 | .Sh HISTORY |
102 | A | |
103 | .Nm ln | |
3d98c418 CL |
104 | command appeared in |
105 | .At v6 . |