Chapter 2: Devices, Disks, Filesystems, and the Kernel


This chapter is a guided tour of the infrastructure in a functioning Linux system, including the system directories, devices, and the kernel. A large part of the material in this chapter deals with filesystems. When you master the workings of Linux filesystems, you will find it much easier to deal with system crashes, manage software, and accommodate new hardware.

Note  

You must do most system configuration and maintenance work as the superuser; this and all remaining chapters assume that you have this capability.

2.1 Directory Hierarchy

As mentioned in Chapter 1, your Linux system has a root directory ( / ). The root contains several subdirectories and possibly a file or two. Keep this area clean; don't let stray files end up here. But don't fall victim to a syndrome that affects many administrators ” removing files in a zealous attempt to keep the system "clean." If you don't know what something does (and can't figure it out), don't remove it.

The names of the directories in / have special meanings that pervade the Linux system in many other subdirectories. For example, there is a /bin directory in the root, but there are also many other bin directories throughout the system, including /usr/bin and /usr/local/bin . All of these bin directories contain executables.

If you want to know the gory details of the many directories on the system, have a look at the Filesystem Hierarchy Standard [Filesystem]. For the most part, the directory names reflect the root and /usr directory patterns described in the next sections.

2.1.1 The Essential Root Subdirectories

The most important of the root directory's subdirectories are the following:

  • bin Contains binary programs (also known as an executables ), which are programs that are ready to run. Most of the basic Unix commands such as ls and cp are in /bin . However, some of the files in /bin are not in binary format because shell scripts perform the tasks of binaries in modern systems.

  • dev Contains device files. Read more about these special files in Section 2.3.

  • etc The core system configuration directory (pronounced EHT-cee). User password, boot, device, networking, and other setup files are here. Many items in /etc are specific to the particular hardware on the machine ” for example, the /etc/X11 directory contains the graphics card configuration.

  • home Holds personal directories for normal users on the system. Most Unix installations conform to this standard.

  • lib An abbreviation for library. In Linux, this directory holds library files containing code that executables can use. There are two types of libraries: static and shared . The /lib directory should contain only shared libraries, but other lib directories such as /usr/lib contain both varieties, as well as other auxiliary files.

  • proc Provides system statistics through a directory-and-file interface that you can browse with standard Unix tools, like those introduced in Chapter 1. Much of the /proc subdirectory structure on Linux is unique, but many other Unix variants have similar features.

  • sbin The place to find system executables. Programs in sbin directories pertain to system management, so regular users usually do not have sbin components in their command paths. Many of the utilities don't work for normal users.

  • tmp The place to put smaller temporary files that you don't care much about. Any user may read to and write from /tmp , but they may not have permission to access another user's files there. Some programs use this directory as a workspace. If something is extremely important, don't put it in /tmp . Most distributions clear /tmp when the machine boots, and some even remove its old files periodically. Don't fill /tmp either, because its space is usually shared with something critical (like the rest of / , for example).

  • usr Pronounced as "user," but this subdirectory does not contain user files (there have been no user files in /usr on Unix systems long before Linux existed). Instead, /usr is a large directory hierarchy that looks a little like the root. The bulk of the Linux system resides in /usr . Many of the directory names in /usr are the same as in the root and hold the same type of files; /usr/bin and /usr/lib are two examples. The primary reason that the root does not contain the complete system is to keep space requirements low. The /usr directory is so important that Section 2.1.3 is dedicated to it.

  • var The "variable" subdirectory, where programs record runtime information. System logging, user tracking, caches, and other files that system programs create and tend all go into /var . There is a /var/tmp similar to /tmp , but the system doesn't wipe it clean on boot.

2.1.2 Other Root Subdirectories

There are a few other interesting subdirectories in the root:

  • boot Contains kernel boot loader files. These files pertain only to the very first stage of the Linux startup process; you will not find information about how Linux starts up its services in this directory.

  • cdrom Where most Linux distributions attach a CD drive; the contents of the disc are under this directory. The root may contain similar directories for other removable devices.

  • opt May contain additional third-party software. Many systems don't use /opt .

2.1.3 The /usr Directory

The /usr directory may look relatively clean at first glance, but a quick look at /usr/bin and /usr/lib reveals that there's a lot here. In addition to the subdirectories that you just read about, /usr contains the following:

  • include Holds header files used by the C compiler (see Section 8.1.2).

  • info Contains GNU info pages (see Section 1.13).

  • local Where administrators can install their own software. Its structure should look like that of / and /usr .

  • man Contains manual pages. Unformatted pages go in the man* directories here (according to the numbered category described in Section 1.13), and human-readable formatted pages go in cat* .

  • share Contains files that should work on other kinds of Unix machines with no loss of functionality. That's the theory, anyway; a true share directory is becoming rare because there are no space issues on modern disks. It is often more of a pain to maintain a share directory than it's worth. In any case, man , info , and some other subdirectories are often found here.

  • X11R6 Holds the core Linux windowing system software, called XFree86. However, the custom configuration files for your computer are usually in /etc/X11 .

  • dict An oddball subdirectory containing dictionaries; /usr/dict/words is one such dictionary file.




How Linux Works
How Linux Works: What Every Superuser Should Know
ISBN: 1593270356
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Brian Ward

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net