home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 24.3 Unlinking Open Files Isn't a Good Idea Chapter 24
Other Ways to Get Disk Space
Next: 24.5 Limiting File Sizes

24.4 Save Space with a Link

You might have copies of the same file in several directories because:

  • 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 ( 8.7 ) .

  • 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 . (Your system should have ln . But it comes with the GNU fileutils, so it's on the Power Tools disc too.) There are lots of advantages to links ( 18.3 ) . One big advantage of hard links is that they don't use any disk space. [1] 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 (unless you have to link across filesystems so hard links can't be used).

[1] 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.

Some people don't use links because they think all links to a file need to have the same name. That's not true. A link can be named myfile in one directory and file.allan in another directory-UNIX keeps it all straight.

- JP

Previous: 24.3 Unlinking Open Files Isn't a Good Idea UNIX Power Tools Next: 24.5 Limiting File Sizes
24.3 Unlinking Open Files Isn't a Good Idea Book Index 24.5 Limiting File Sizes

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System