-->
Previous Table of Contents Next


The /lib directory contains a library of functions needed by the C compiler. Even if you don’t have a C compiler on your system, this directory is important because it contains all the shared libraries that application programs can call. A shared library is loaded into memory only when the command calling it is run. This arrangement keeps executable programs small. Otherwise, every running program contains duplicate code, requiring a lot more disk space to store and a lot more memory to run.

The /tmp directory is used for temporary storage. Programs that use /tmp generally clean up after themselves and delete any temporary files. If you use /tmp, be sure to delete any files before logging out. Because the system automatically deletes the contents of this directory periodically, don’t keep anything you might need later in it.

The /bin directory keeps all the executable programs needed to boot the system and is usually home for the most commonly used Linux commands. Note, however, that an executable program doesn’t have to be binary (which the name bin implies). Several smaller programs in /bin are, in fact, shell scripts.

The /usr directory contains everything else. Your PATH variable contains the string /bin:/usr/bin because the /usr/bin directory contains all the Linux commands that aren’t in the /bin directory. This arrangement has a historical precedence. In the early days of Linux, hard disks weren’t very big. Linux needs at least the /etc/tmp/ and /bin directories to bootstrap (that is, start executing) itself. Because the disks of the early Linux era held only those three directories, everything else was on a disk that could be mounted after Linux was up and running. When Linux was still a relatively small operating system, placing additional subdirectories in the /usr directory wasn’t much of a burden. It allowed a moderately sized Linux system to exist with just two disks: a root disk and a /usr disk.

The /usr/adm directory contains all the accounting and diagnostic information needed by the system administrator. If both system accounting and diagnostic programs are turned off, this directory is effectively empty.

The /include directory contains all the source code used by #include statements in C programs. You’ll have at least read permission for this directory because it contains all the code fragments and structures that define your system. You shouldn’t modify any of the files in this directory because they were crafted (carefully, you can assume) by your system vendor.

The /usr/spool directory contains all the transient data used by the lp print system, the cron daemon, and the UUCP communications system. Files “spooled” to the printer are kept in the /spool directory until they’re printed. Any programs waiting to be run by cron, including all the crontab files and pending at and batch jobs, are also stored here.

The /usr/lib directory contains everything else that’s part of the standard Linux system. In general, the /usr/lib directory represents the organized chaos hidden beneath the relatively well-disciplined Linux system. This directory contains programs called by other programs found in /bin and /usr/bin as well as configuration files for terminals and printers, the mail system, cron, and the UUCP communications system.

The /usr directory contains all the subdirectories assigned to users. The general convention is this: If your login ID is “mary,” your home directory is /usr/mary.

This directory arrangement made a lot of sense when disks were small and expensive, but with the advent of very large disks at (relatively) inexpensive prices, there are better ways of organizing Linux, as evidenced by the new directory structure discussed in the next section.

Linux Directories

One problem with the classical structure of UNIX is that backing up your data files is difficult with a fragmented /usr directory. Three different levels of backup generally are required in a system: the basic system itself, any changes to the tables that define the basic system for a specific site, and user data.

The basic system should be backed up only once with changes to the controlling tables backed up when there are changes. User data changes all the time and should be backed up frequently. The typical Linux directory structure is shown here, but your structure might be a little different depending on what packages you installed:


/

      /etc

            /passwd    (user database)

            /rc.d    (system initialization scripts)

/sbin

/bin

/tmp

/var

/lib

/home

      / <your user name here>    (user accounts)

/install

/usr

      /bin

/proc

The /bin, /etc, and /tmp directories have the same function as they do in the classic structure. System definition tables are moved into the /var directory so that whenever the operation of the system changes, you can back up only that directory.

What’s new is that all system programs are moved into the /sbin directory. All the standard Linux programs are in /usr/bin, which is linked to /bin. For compatibility, all the classic directories are maintained with symbolic links. The /usr directory, which no longer contains user data, has been reorganized to make sense from the chaos that once was the /usr/lib directory.

From Here…

In this chapter, you examined how Linux uses files and directories and how the file permission system protects your data. You learned how to change the permissions on files and directories and what the meaning of a special file is. Finally, you studied the names and functions of the most common directories found in Linux. For more information, see the following chapters:

  Chapter 7, “Understanding System Administration,” explains how to set up new users with file permissions.
  Chapter 14, “Managing File Systems,” discusses the concept of file systems and how they’re organized.
  Chapter 17, “Managing Files and Directories,” discusses how to organize and use your files and directories.


Previous Table of Contents Next