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