1*c31c7074SLionel Sambuc.\" $NetBSD: ln.1,v 1.25 2012/03/22 07:58:17 wiz Exp $ 2*c31c7074SLionel Sambuc.\" 3*c31c7074SLionel Sambuc.\" Copyright (c) 1980, 1990, 1993 4*c31c7074SLionel Sambuc.\" The Regents of the University of California. All rights reserved. 5*c31c7074SLionel Sambuc.\" 6*c31c7074SLionel Sambuc.\" This code is derived from software contributed to Berkeley by 7*c31c7074SLionel Sambuc.\" the Institute of Electrical and Electronics Engineers, Inc. 8*c31c7074SLionel Sambuc.\" 9*c31c7074SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 10*c31c7074SLionel Sambuc.\" modification, are permitted provided that the following conditions 11*c31c7074SLionel Sambuc.\" are met: 12*c31c7074SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 13*c31c7074SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 14*c31c7074SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 15*c31c7074SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 16*c31c7074SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 17*c31c7074SLionel Sambuc.\" 3. Neither the name of the University nor the names of its contributors 18*c31c7074SLionel Sambuc.\" may be used to endorse or promote products derived from this software 19*c31c7074SLionel Sambuc.\" without specific prior written permission. 20*c31c7074SLionel Sambuc.\" 21*c31c7074SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22*c31c7074SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23*c31c7074SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24*c31c7074SLionel Sambuc.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25*c31c7074SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26*c31c7074SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27*c31c7074SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28*c31c7074SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29*c31c7074SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30*c31c7074SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*c31c7074SLionel Sambuc.\" SUCH DAMAGE. 32*c31c7074SLionel Sambuc.\" 33*c31c7074SLionel Sambuc.\" @(#)ln.1 8.2 (Berkeley) 12/30/93 34*c31c7074SLionel Sambuc.\" 35*c31c7074SLionel Sambuc.Dd October 29, 2007 36*c31c7074SLionel Sambuc.Dt LN 1 37*c31c7074SLionel Sambuc.Os 38*c31c7074SLionel Sambuc.Sh NAME 39*c31c7074SLionel Sambuc.Nm ln 40*c31c7074SLionel Sambuc.Nd make links 41*c31c7074SLionel Sambuc.Sh SYNOPSIS 42*c31c7074SLionel Sambuc.Nm 43*c31c7074SLionel Sambuc.Op Fl fhinsv 44*c31c7074SLionel Sambuc.Ar source_file 45*c31c7074SLionel Sambuc.Op Ar target_file 46*c31c7074SLionel Sambuc.Nm 47*c31c7074SLionel Sambuc.Op Fl fhinsv 48*c31c7074SLionel Sambuc.Ar source_file ... target_dir 49*c31c7074SLionel Sambuc.Sh DESCRIPTION 50*c31c7074SLionel SambucThe 51*c31c7074SLionel Sambuc.Nm 52*c31c7074SLionel Sambucutility creates a new directory entry (linked file) which has the 53*c31c7074SLionel Sambucsame modes as the original file. 54*c31c7074SLionel SambucIt is useful for maintaining multiple copies of a file in many places 55*c31c7074SLionel Sambucat once without using up storage for the 56*c31c7074SLionel Sambuc.Dq copies ; 57*c31c7074SLionel Sambucinstead, a link 58*c31c7074SLionel Sambuc.Dq points 59*c31c7074SLionel Sambucto the original copy. 60*c31c7074SLionel SambucThere are two types of links: hard links and symbolic links. 61*c31c7074SLionel SambucHow a link 62*c31c7074SLionel Sambuc.Dq points 63*c31c7074SLionel Sambucto a file is one of the differences between a hard or symbolic link. 64*c31c7074SLionel Sambuc.Pp 65*c31c7074SLionel SambucThe options are as follows: 66*c31c7074SLionel Sambuc.Bl -tag -width flag 67*c31c7074SLionel Sambuc.It Fl f 68*c31c7074SLionel SambucUnlink any already existing file, permitting the link to occur. 69*c31c7074SLionel Sambuc.It Fl h 70*c31c7074SLionel SambucIf the 71*c31c7074SLionel Sambuc.Ar target_file 72*c31c7074SLionel Sambucor 73*c31c7074SLionel Sambuc.Ar target_dir 74*c31c7074SLionel Sambucis a symbolic link, do not follow it. 75*c31c7074SLionel SambucThis is most useful with the 76*c31c7074SLionel Sambuc.Fl f 77*c31c7074SLionel Sambucoption, to replace a symlink which may point to a directory. 78*c31c7074SLionel Sambuc.It Fl i 79*c31c7074SLionel SambucCause 80*c31c7074SLionel Sambuc.Nm 81*c31c7074SLionel Sambucto write a prompt to standard error if the target file exists. 82*c31c7074SLionel SambucIf the response from the standard input begins with the character 83*c31c7074SLionel Sambuc.Sq Li y 84*c31c7074SLionel Sambucor 85*c31c7074SLionel Sambuc.Sq Li Y , 86*c31c7074SLionel Sambucthen unlink the target file so that the link may occur. 87*c31c7074SLionel SambucOtherwise, do not attempt the link. 88*c31c7074SLionel Sambuc(The 89*c31c7074SLionel Sambuc.Fl i 90*c31c7074SLionel Sambucoption overrides any previous 91*c31c7074SLionel Sambuc.Fl f 92*c31c7074SLionel Sambucoptions.) 93*c31c7074SLionel Sambuc.It Fl n 94*c31c7074SLionel SambucSame as 95*c31c7074SLionel Sambuc.Fl h , 96*c31c7074SLionel Sambucfor compatibility with other 97*c31c7074SLionel Sambuc.Nm 98*c31c7074SLionel Sambucimplementations, namely GNU coreutils. 99*c31c7074SLionel Sambuc.It Fl s 100*c31c7074SLionel SambucCreate a symbolic link. 101*c31c7074SLionel Sambuc.It Fl v 102*c31c7074SLionel SambucCause 103*c31c7074SLionel Sambuc.Nm 104*c31c7074SLionel Sambucto be verbose, showing files as they are processed. 105*c31c7074SLionel Sambuc.El 106*c31c7074SLionel Sambuc.Pp 107*c31c7074SLionel SambucBy default 108*c31c7074SLionel Sambuc.Nm 109*c31c7074SLionel Sambucmakes 110*c31c7074SLionel Sambuc.Em hard 111*c31c7074SLionel Sambuclinks. 112*c31c7074SLionel SambucA hard link to a file is indistinguishable from the original directory entry; 113*c31c7074SLionel Sambucany changes to a file are effective independent of the name used to reference 114*c31c7074SLionel Sambucthe file. 115*c31c7074SLionel SambucHard links may not normally refer to directories and may not span file systems. 116*c31c7074SLionel Sambuc.Pp 117*c31c7074SLionel SambucA symbolic link contains the name of the file to 118*c31c7074SLionel Sambucwhich it is linked. 119*c31c7074SLionel SambucThe referenced file is used when an 120*c31c7074SLionel Sambuc.Xr open 2 121*c31c7074SLionel Sambucoperation is performed on the link. 122*c31c7074SLionel SambucA 123*c31c7074SLionel Sambuc.Xr stat 2 124*c31c7074SLionel Sambucon a symbolic link will return the linked-to file; an 125*c31c7074SLionel Sambuc.Xr lstat 2 126*c31c7074SLionel Sambucmust be done to obtain information about the link. 127*c31c7074SLionel SambucThe 128*c31c7074SLionel Sambuc.Xr readlink 2 129*c31c7074SLionel Sambuccall may be used to read the contents of a symbolic link. 130*c31c7074SLionel SambucSymbolic links may span file systems and may refer to directories. 131*c31c7074SLionel Sambuc.Pp 132*c31c7074SLionel SambucGiven one or two arguments, 133*c31c7074SLionel Sambuc.Nm 134*c31c7074SLionel Sambuccreates a link to an existing file 135*c31c7074SLionel Sambuc.Ar source_file . 136*c31c7074SLionel SambucIf 137*c31c7074SLionel Sambuc.Ar target_file 138*c31c7074SLionel Sambucis given, the link has that name; 139*c31c7074SLionel Sambuc.Ar target_file 140*c31c7074SLionel Sambucmay also be a directory in which to place the link; 141*c31c7074SLionel Sambucotherwise it is placed in the current directory. 142*c31c7074SLionel SambucIf only the directory is specified, the link will be made 143*c31c7074SLionel Sambucto the last component of 144*c31c7074SLionel Sambuc.Ar source_file . 145*c31c7074SLionel Sambuc.Pp 146*c31c7074SLionel SambucGiven more than two arguments, 147*c31c7074SLionel Sambuc.Nm 148*c31c7074SLionel Sambucmakes links in 149*c31c7074SLionel Sambuc.Ar target_dir 150*c31c7074SLionel Sambucto all the named source files. 151*c31c7074SLionel SambucThe links made will have the same name as the files being linked to. 152*c31c7074SLionel Sambuc.Sh SEE ALSO 153*c31c7074SLionel Sambuc.Xr link 2 , 154*c31c7074SLionel Sambuc.Xr lstat 2 , 155*c31c7074SLionel Sambuc.Xr readlink 2 , 156*c31c7074SLionel Sambuc.Xr stat 2 , 157*c31c7074SLionel Sambuc.Xr symlink 2 , 158*c31c7074SLionel Sambuc.Xr symlink 7 159*c31c7074SLionel Sambuc.Sh STANDARDS 160*c31c7074SLionel SambucThe 161*c31c7074SLionel Sambuc.Nm 162*c31c7074SLionel Sambucutility conforms to 163*c31c7074SLionel Sambuc.St -p1003.2-92 . 164*c31c7074SLionel Sambuc.Pp 165*c31c7074SLionel SambucThe 166*c31c7074SLionel Sambuc.Fl v 167*c31c7074SLionel Sambucoption is an extension to 168*c31c7074SLionel Sambuc.St -p1003.2-92 . 169*c31c7074SLionel Sambuc.Sh HISTORY 170*c31c7074SLionel SambucA 171*c31c7074SLionel Sambuc.Nm 172*c31c7074SLionel Sambucutility appeared in 173*c31c7074SLionel Sambuc.At v6 . 174