## 15.4. Save Space with a Link

You might have copies of the same file in several directories for the following reasons:

- Several different users need to read it (a data file, a program setup file, a telephone list, etc.).

- It's a program that more than one person wants to use. For some reason, you don't want to keep one central copy and put its directory in your search path (Section 27.6).

- The file has a strange name or it's in a directory you don't usually use. You want a name that's easier to type, but you can't use mv.

Instead of running cp, think about ln. There are lots of advantages to links (Section 10.3). One big advantage of hard links is that they don't use any disk space.[46] The bigger the file, the more space you save with a link. A symbolic link always takes some disk space, so a hard link might be better for ekeing the most space out of your disk. Of course, you have to use a symbolic link if you want to link across filesystems, and symbolic links are much more obvious to other people, so a symlink is less likely to confuse people. Generally the clarity is worth the little bit of extra disk space.

> [46]The link entry takes a few characters in the directory where you make the link. Unless this makes the directory occupy another disk block, the space available on the disk doesn't change.

-- JP

Copyright © 2003 O'Reilly & Associates. All rights reserved.