Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

How to make a file appear in multiple directories

Tech Computer Center logo

Most files appear in only one directory. However, there are ways to make a file appear in more than one place.

You can use a hard link to add a file to a directory. For example, to make file /u/bob/janus appear also in directory ~/hot, use this command:

    % ln /u/bob/janus ~/hot

When a file is hard-linked to multiple directories, it lives equally in all of the directories. If it is deleted from one directory with the rm command, it will still appear in the others.

If your ln fails with a message about a "cross-device link", you can still get the same effect using a soft link; use the -s option in the ln command. For example:

    % ln -s /u/bob/janus ~/hot

Soft or symbolic links are different in one important respect from hard links. You can create a soft link to a file that does not exist. If the file still doesn't exist when the link is used, you'll get the message "No such file or directory."

Next: How to move an entire directory tree
See also: How to organize large collections of files
Previous: Changing the name or location of a directory
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman,
Last updated: 1995/12/04 19:39:34 UT
QR two-dimensional bar code