1.\"- 2.\" Copyright (c) 1980, 1990, 1993 3.\" The Regents of the University of California. All rights reserved. 4.\" 5.\" This code is derived from software contributed to Berkeley by 6.\" the Institute of Electrical and Electronics Engineers, Inc. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 4. Neither the name of the University nor the names of its contributors 17.\" may be used to endorse or promote products derived from this software 18.\" without specific prior written permission. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30.\" SUCH DAMAGE. 31.\" 32.\" @(#)ln.1 8.2 (Berkeley) 12/30/93 33.\" $FreeBSD$ 34.\" 35.Dd February 14, 2006 36.Dt LN 1 37.Os 38.Sh NAME 39.Nm ln , 40.Nm link 41.Nd make links 42.Sh SYNOPSIS 43.Nm 44.Op Fl s Op Fl F 45.Op Fl f | i 46.Op Fl hnv 47.Ar source_file 48.Op Ar target_file 49.Nm 50.Op Fl s Op Fl F 51.Op Fl f | i 52.Op Fl hnv 53.Ar source_file ... 54.Ar target_dir 55.Nm link 56.Ar source_file Ar target_file 57.Sh DESCRIPTION 58The 59.Nm 60utility creates a new directory entry (linked file) which has the 61same modes as the original file. 62It is useful for maintaining multiple copies of a file in many places 63at once without using up storage for the 64.Dq copies ; 65instead, a link 66.Dq points 67to the original copy. 68There are two types of links; hard links and symbolic links. 69How a link 70.Dq points 71to a file is one of the differences between a hard and symbolic link. 72.Pp 73The options are as follows: 74.Bl -tag -width flag 75.It Fl f 76If the target file already exists, 77then unlink it so that the link may occur. 78(The 79.Fl f 80option overrides any previous 81.Fl i 82options.) 83.It Fl F 84If the target file already exists and is a directory, then remove it 85so that the link may occur. 86The 87.Fl F 88option should be used with either 89.Fl f 90or 91.Fl i 92options. 93If none is specified, 94.Fl f 95is implied. 96The 97.Fl F 98option is a no-op unless 99.Fl s 100option is specified. 101.It Fl h 102If the 103.Ar target_file 104or 105.Ar target_dir 106is a symbolic link, do not follow it. 107This is most useful with the 108.Fl f 109option, to replace a symlink which may point to a directory. 110.It Fl i 111Cause 112.Nm 113to write a prompt to standard error if the target file exists. 114If the response from the standard input begins with the character 115.Sq Li y 116or 117.Sq Li Y , 118then unlink the target file so that the link may occur. 119Otherwise, do not attempt the link. 120(The 121.Fl i 122option overrides any previous 123.Fl f 124options.) 125.It Fl n 126Same as 127.Fl h , 128for compatibility with other 129.Nm 130implementations. 131.It Fl s 132Create a symbolic link. 133.It Fl v 134Cause 135.Nm 136to be verbose, showing files as they are processed. 137.El 138.Pp 139By default, 140.Nm 141makes 142.Em hard 143links. 144A hard link to a file is indistinguishable from the original directory entry; 145any changes to a file are effectively independent of the name used to reference 146the file. 147Hard links may not normally refer to directories and may not span file systems. 148.Pp 149A symbolic link contains the name of the file to 150which it is linked. 151The referenced file is used when an 152.Xr open 2 153operation is performed on the link. 154A 155.Xr stat 2 156on a symbolic link will return the linked-to file; an 157.Xr lstat 2 158must be done to obtain information about the link. 159The 160.Xr readlink 2 161call may be used to read the contents of a symbolic link. 162Symbolic links may span file systems and may refer to directories. 163.Pp 164Given one or two arguments, 165.Nm 166creates a link to an existing file 167.Ar source_file . 168If 169.Ar target_file 170is given, the link has that name; 171.Ar target_file 172may also be a directory in which to place the link; 173otherwise it is placed in the current directory. 174If only the directory is specified, the link will be made 175to the last component of 176.Ar source_file . 177.Pp 178Given more than two arguments, 179.Nm 180makes links in 181.Ar target_dir 182to all the named source files. 183The links made will have the same name as the files being linked to. 184.Pp 185When the utility is called as 186.Nm link , 187exactly two arguments must be supplied, 188neither of which may specify a directory. 189No options may be supplied in this simple mode of operation, 190which performs a 191.Xr link 2 192operation using the two passed arguments. 193.Sh COMPATIBILITY 194The 195.Fl h , 196.Fl i , 197.Fl n 198and 199.Fl v 200options are non-standard and their use in scripts is not recommended. 201They are provided solely for compatibility with other 202.Nm 203implementations. 204.Pp 205The 206.Fl F 207option is 208.Fx 209extention and should not be used in portable scripts. 210.Sh SEE ALSO 211.Xr link 2 , 212.Xr lstat 2 , 213.Xr readlink 2 , 214.Xr stat 2 , 215.Xr symlink 2 , 216.Xr symlink 7 217.Sh STANDARDS 218The 219.Nm 220utility conforms to 221.St -p1003.2-92 . 222.Pp 223The simplified 224.Nm link 225command conforms to 226.St -susv2 . 227.Sh HISTORY 228An 229.Nm 230command appeared in 231.At v1 . 232