10.7 Aliasing files with ln

ln(1) is used to create links between files. These links can be either hard links or soft (symbolic) links. The differences between the two kinds of links were discussed in Section 9.3. If you wanted to make a symbolic link to the directory /var/media/mp3 and place the link in your home directory, you would do this:

% ln -s /var/media/mp3 ~/mp3

The -s option tells ln to make a symbolic link. The next option is the target of the link, and the final option is what to call the link. In this case, it will just make a file called mp3 in your home directory that points to /var/media/mp3. You can call the link itself whatever you want by just changing the last option.

Making a hard link is just as simple. All you have to do is leave off the -s option. Hard links may not normally refer to directories or span file systems, however. To create a hard link /usr/bin/email to /usr/bin/mutt, simply type the following:

# ln /usr/bin/mutt /usr/bin/email