Chapter 4. How Linux Works
Before you can effectively use a desktop environment, you need to know some Linux fundamentals. This chapter explains basic Linux concepts that underlie graphical and nongraphical system use. It describes Linux
|
4.1
|
4.2 How Linux Organizes DataIn order to make the most effective use of your Linux system, you must understand how Linux organizes data. If you're familiar with Windows or another operating system, you'll find it easy to learn how Linux organizes data, because most operating systems organize their data in similar ways. This section explains how Linux organizes data and introduces you to several important Linux commands that work with directories and files. 4.2.1 Devices
Linux receives data from, sends data to, and stores data on
devices
. A device
Table 4-1. Typical Linux devices
4.2.2 Filesystems
Whether you're using Windows or Linux, you must format a partition before you can store data on it. The installation procedure automatically formats the partitions you create during system installation. When the installation procedure formats a partition, it also
Just as every partition must have a filesystem, every CD-ROM and floppy diskette must have a filesystem. The filesystem of a CD-ROM is written when the disk is created; the filesystem of a floppy diskette is rewritten each time you format it.
Windows 98 lets you choose to format a partition as FAT or FAT32. Windows NT, 2000, and XP also support the NTFS filesystem type. Linux supports a wider variety of filesystem types; Table 4-2 summarizes the most common ones. The most important filesystem types are
ext3
, which is used for Linux native partitions;
msdos
, which is used for FAT partitions (and floppy diskettes) of the
Table 4-2. Common filesystem types
4.2.3 Directories and PathsIf you've used MS-DOS, you're familiar with the concepts of file and directory and with various MS-DOS commands that work with files and directories. Under Linux, files and directories work much as they do under MS-DOS. 4.2.3.1 Home and working directories
When you log in to Linux, you're placed in a special directory known as your
home directory
. Generally, each user has a distinct home directory, where the user creates personal files. This makes it simple for the
The current directory— or current working directory , as it's sometimes called—is the directory you're currently working in. When you log in to Linux, you're automatically placed in your home directory. 4.2.3.2 The directory tree
The directories of a Linux system are organized as a hierarchy. Unlike MS-DOS, which provides a separate hierarchy for each partition, Linux provides a single hierarchy that includes every partition. The topmost directory of the directory tree is the
root directory
, which is written using a forward slash (
/
), not the backward slash (
\
) used by MS-DOS to
Figure 4-1 shows a hypothetical Linux directory tree; a real Linux system contains many more directories. The root directory contains six subdirectories: /bin , /dev , /etc , /home , /tmp , and /usr . The /home directory has two subdirectories; each is the home directory of a user and has the same name as the user who owns it. The user named bill has created two subdirectories in his home directory: books and school . The user named patrick has created the single school subdirectory in his home directory. Figure 4-1. A hypothetical Linux directory tree
Each directory (other than the root directory) is contained in a directory known as its parent directory. For example, the parent directory of the bill directory is home .
4.2.3.3 Absolute and relative pathnamesIf you look closely at Figure 4-1, you'll see that two directories named school exist; one is a subdirectory of bill and the other is a subdirectory of patrick . To avoid confusion that could result when several directories have the same name, directories are specified using pathnames .
There are two kinds of pathnames:
absolute
and
relative
. The absolute pathname of a directory traces the location of the directory beginning at the root directory; you form the pathname as a list of directories, separated by forward
When a subdirectory is many levels below the root directory, its absolute pathname may be long and cumbersome. In such a case, it's often more
Linux provides two special directory
4.2.4 File Permissions
Unlike Windows 9
x
, but like other varieties of Unix and Windows NT/2000, Linux is a multiuser operating system. Therefore, it includes mechanisms to protect data from unauthorized access. The primary protection mechanism restricts access to directories and files based on the identity of the user who
Each directory and file has an associated user, called the owner . The user who initially creates a file is the owner of the file. Each user belongs to one or more sets of users known as groups . Each directory and file has an associated group, which is assigned when the directory or file is created. The user and the group can be changed later.
Access permissions, also known as
modes
, determine what operations a user can perform on a directory or file. Table 4-3 lists the most common permissions and explains the meaning of each. Notice that permissions work differently for directories than for files. For example, permission
r
denotes the ability to list the contents of a directory or
read
the contents of a file. A directory or file can have multiple permissions. Only the listed permissions are granted; any other operations are
Table 4-3. Common access permissions
The access modes of a directory or file consist of three sets of permissions:
The
ls
command, which you'll meet in Chapter 7, lists the file access modes in the second column of its long output format, as shown in Figure 4-2. The GNOME and KDE file managers use this same format. The column contains nine
Figure 4-2. Access modes as shown by the ls command
Figure 4-3. Access modes specify three permissions
4.2.5 Mounting and Unmounting Filesystems
You cannot access a hard drive partition, CD-ROM, or floppy disk until the
Before you can remove media from a device, you must unmount it. You can
|