-->
Previous Table of Contents Next


PART III
Managing the File System

14  Managing File Systems
15  Using Samba
16  Understanding the File and Directory System
17  Managing Files and Directories

Chapter 14
Managing File Systems

by Jack Tackett

In this chapter
Understanding File Systems
Mounting and Unmounting File Systems
Understanding the Network File System
Maintaining File Systems
Using the fsck Command
Creating and Formatting File Systems
Using Swap Files and Partitions

File systems form the basis for all data on a Linux system. Linux programs, libraries, system files, and user files all reside on file systems. Proper management of file systems is critical because all your data and programs exist on top of file systems.

Many of the steps outlined in this chapter are performed automatically when you install Linux. However, you should learn to manage your file systems so that you can create, manage, and maintain your Linux system. Understanding file-system management is critical to successful systems administration. Your file system must work properly for your Linux system to work at all.

Understanding File Systems

Under Linux, the file space that’s visible to users is based on a tree structure, with the root at the top. The various directories and files in this space branch downward from the root. The top directory, /, is known as the root directory. Figure 14.1 gives a graphical example of a tree structure.


Fig. 14.1  Picture the Linux file system as an upside-down tree, with the root at the top and the branches and leaves spreading downward.

To users, this directory tree looks like a seamless entity—they just see directories and files. In reality, many of the directories in the file tree are physically located on different partitions on a disk, on different disks, or even on different computers. When one of these disk partitions is attached to the file tree at a directory known as a mount point, the mount point and all directories below it are referred to as a file system.

The Linux operating system is made up of several directories and many different files. Depending on how you selected your installation, these directories may be different file systems. Typically, most of the operating system resides on two file systems: the root file system, known as /, and a file system mounted under /usr (pronounced user).

If you change directories to the root directory with the cd / command and ask for a directory listing, you see several directories. These make up the contents of the root file system and provide the mount points for other file systems as well.

The /bin directory contains executable programs, known as binaries. (In fact, the directory named /bin is short for binary.) These programs are essential system files. Many Linux commands, such as ls, are actually programs found in this directory.

The /sbin directory is also used to store system binary files. Most files in this directory are used for system administration purposes.

The /etc directory is very important, containing many of the Linux system configuration files. Essentially, these files give your Linux system its “personality.” The password file, passwd, is found here, as is the list of file systems to mount at startup, fstab. Also, this directory contains the startup scripts for Linux, the list of hosts with IP addresses that you want permanently recorded, and many other types of configuration information.

The shared libraries that programs use when they run are stored in the /lib directory. By using shared libraries, many programs can reuse the same code, and these libraries can be stored in a common place, thus reducing the size of your programs at run time.

The /dev directory contains special files known as device files, which are used to access all the different types of hardware on your system. For example, the /dev/mouse file is for reading input from the mouse. By organizing access to hardware devices in this way, Linux effectively makes the interface to a hardware device look like any other piece of software. This means that you, in many cases, can use the same syntax that you use with software to perform operations on computer hardware devices. For example, to create a tape archive of your home directory on a floppy drive, you can use the following command:


tar -cdf /dev/fd0 -tackett

/dev/fd0 indicates that the tar command should use the floppy drive identified by fd0.


See “Using tar,” p. 229

Many of the devices in the /dev directory are in logical groups. Table 14.1 lists some of the most commonly used devices in the /dev directory.

Table 14.1 Commonly Used Devices in the /dev Directory

Device File Description

/dev/console The system console, which is the computer monitor physically connected to your Linux system.
/dev/hd The device driver interface to IDE hard drives. The /dev/hda1 device refers to the first partition on hard drive hda. The device /dev/hda refers to the entire hard disk hda.
/dev/sd The device driver interface for SCSI disks. The same conventions for SCSI disks and partitions apply as they do to the IDE /dev/hd devices.
/dev/fd Device drivers that provide support for floppy drives. /dev/fd0 is the first floppy drive and /dev/fd1 is the second floppy drive.
/dev/st The device driver for SCSI tape drives.
/dev/tty Device drivers that provide different consoles for user input. The name comes from when terminals known as teletypes were physically hooked to a UNIX system. Under Linux, these files provide support for the virtual consoles that can be accessed by pressing <Alt-F1> through <Alt-F6>. These virtual consoles provide separate simultaneous local login sessions.
/dev/pty Device drivers that provide support for pseudo-terminals, which are used for remote login sessions such as login sessions using Telnet.
/dev/ttyS The serial interface ports on your computer. /dev/ttyS0 corresponds to COM1 under MS-DOS. If you have a serial mouse, /dev/mouse is a symbolic link to the appropriate ttyS device that your mouse is connected to.
/dev/cua Special call-out devices used with modems.
/dev/null A very special device—essentially a black hole. All data written to /dev/null is lost forever. This can be very useful if you want to run a command and throw away the standard output or the standard error. Also, if /dev/null is used as an input file, a file of zero length is created.


Previous Table of Contents Next