1ln(1B)             SunOS/BSD Compatibility Package Commands             ln(1B)
2
3
4

NAME

6       ln - make hard or symbolic links to files
7

SYNOPSIS

9       /usr/ucb/ln [-fs] filename [linkname]
10
11
12       /usr/ucb/ln [-fs] pathname... directory
13
14

DESCRIPTION

16       The /usr/ucb/ln utility creates an additional directory entry, called a
17       link, to a file or directory. Any number of links can be assigned to  a
18       file.   The  number of links does not affect other file attributes such
19       as size, protections, data, etc.
20
21
22       filename is the name of the original file or directory. linkname is the
23       new  name to associate with the file or filename.  If linkname is omit‐
24       ted, the last component of filename is used as the name of the link.
25
26
27       If the last argument is the name of a  directory,  symbolic  links  are
28       made in that directory for each pathname argument; /usr/ucb/ln uses the
29       last component of each pathname as the name of each link in  the  named
30       directory.
31
32
33       A  hard  link (the default) is a standard directory entry just like the
34       one made when the file was created.  Hard links can  only  be  made  to
35       existing  files.   Hard  links cannot be made across file systems (disk
36       partitions, mounted file systems).  To remove a file, all hard links to
37       it  must  be removed, including the name by which it was first created;
38       removing the last hard link releases  the  inode  associated  with  the
39       file.
40
41
42       A  symbolic link, made with the -s option, is a special directory entry
43       that points to another named file. Symbolic links can span file systems
44       and point to directories.  In fact, you can create a symbolic link that
45       points to a file that is currently absent from the file system;  remov‐
46       ing  the  file  that it points to does not affect or alter the symbolic
47       link itself.
48
49
50       A symbolic link to a  directory  behaves  differently  than  you  might
51       expect  in  certain  cases.  While an ls(1) on such a link displays the
52       files in the pointed-to directory,  an  `ls  -l'  displays  information
53       about the link itself:
54
55         example% /usr/ucb/ln -s dir link
56         example% ls link
57         file1 file2 file3 file4
58         example% ls -l link
59         lrwxrwxrwx  1 user            7 Jan 11 23:27 link → dir
60
61
62
63
64       When  you  use  cd(1) to change to a directory through a symbolic link,
65       you wind up in the pointed-to location within the  file  system.   This
66       means that the parent of the new working directory is not the parent of
67       the symbolic link, but rather, the parent of the pointed-to  directory.
68       For instance, in the following case the final working directory is /usr
69       and not /home/user/linktest.
70
71         example% pwd
72         /home/user/linktest
73         example% /usr/ucb/ln -s /var/tmp symlink
74         example% cd symlink
75         example% cd ..
76         example% pwd
77         /usr
78
79
80
81
82       C shell user's can avoid any resulting navigation problems by using the
83       pushd and popd built-in commands instead of cd.
84

OPTIONS

86       -f    Force  a  hard link to a directory. This option is only available
87             to the super-user, and should be used with extreme caution.
88
89
90       -s    Create a symbolic link or links.
91
92

USAGE

94       See largefile(5) for the description of the behavior of ln when encoun‐
95       tering files greater than or equal to 2 Gbyte ( 2^31 bytes).
96

EXAMPLES

98       Example 1 The /usr/ucb/ln command
99
100
101       The commands below illustrate the effects of the different forms of the
102       /usr/ucb/ln command:
103
104
105         example% /usr/ucb/ln file link
106         example% ls -F file link
107         file   link
108         example% /usr/ucb/ln -s file symlink
109         example% ls -F file symlink
110         file   symlink@
111         example% ls -li file link symlink
112          10606 -rw-r--r--  2 user            0 Jan 12 00:06 file
113          10606 -rw-r--r--  2 user            0 Jan 12 00:06 link
114          10607 lrwxrwxrwx  1 user            4 Jan 12 00:06 symlink → file
115         example% /usr/ucb/ln -s nonesuch devoid
116         example% ls -F devoid
117         devoid@
118         example% cat devoid
119         devoid: No such file or directory
120         example% /usr/ucb/ln -s /proto/bin/* /tmp/bin
121         example% ls -F /proto/bin /tmp/bin
122         /proto/bin:
123         x*      y*      z*
124
125         /tmp/bin:
126         x@      y@      z@
127
128
129

ATTRIBUTES

131       See attributes(5) for descriptions of the following attributes:
132
133
134
135
136       ┌─────────────────────────────┬─────────────────────────────┐
137       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
138       ├─────────────────────────────┼─────────────────────────────┤
139       │Availability                 │SUNWscpu                     │
140       └─────────────────────────────┴─────────────────────────────┘
141

SEE ALSO

143       cp(1), ls(1), mv(1), rm(1), link(2), readlink(2), stat(2),  symlink(2),
144       attributes(5), largefile(5)
145

NOTES

147       When  the  last argument is a directory, simple basenames should not be
148       used for pathname arguments.  If a basename is used, the resulting sym‐
149       bolic link points to itself:
150
151         example% /usr/ucb/ln -s file /tmp
152         example% ls -l /tmp/file
153         lrwxrwxrwx  1 user            4 Jan 12 00:16 /tmp/file → file
154         example% cat /tmp/file
155         /tmp/file: Too many levels of symbolic links
156
157
158
159
160       To  avoid  this  problem, use full pathnames, or prepend a reference to
161       the PWD variable to files in the working directory:
162
163         example% rm /tmp/file
164         example% /usr/ucb/ln -s $PWD/file /tmp
165         lrwxrwxrwx  1 user 4       Jan 12 00:16 /tmp/file →
166         /home/user/subdir/file
167
168
169
170
171
172SunOS 5.11                        11 Mar 1994                           ln(1B)
Impressum