DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Working with files and directories

Creating a link to a file

To create a link to a file, use the ln(C) command, as follows:

ln filename linkname

For example, suppose you have a file called user_guide which is located in /u/workgrp/tasks/projects. To work on this file you would normally cd to that directory before opening the file. However, by creating a link to the file, you can access it from your current directory (without needing to enter the full path of the file). To do this, type the following:

   $ ln /u/workgrp/tasks/projects/user_guide my_guide
The my_guide argument identifies the link. Whenever you want to work on the file, which is now known to the system by two names (user_guide and my_guide), you can access it from the current directory by using my_guide as the filename.

You must have write permission on a directory before you can create a link that involves that directory or a file in that directory. You cannot create a hard link (the kind of link described above) to a directory or a file on a different filesystem. To create a link to a directory or a different filesystem, you must use a symbolic link. See ``Creating a link to a directory'' for details.

Links can be removed using rm. If a file has several links, it is not physically deleted until the the final link is removed.


Next topic: Finding out whether a file has hard links
Previous topic: Creating links to files and directories

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003