username
will output the informa-
tion as shown previously for foxr. The instruction
repquota
filesystem
will output
all quotas for the users/groups of the given file system.
10.5 LINUX TOP-LEVEL DIRECTORIES REVISITED
We visited the top-level Linux directory structure in Chapter 3. Here, we focus our atten-
tion on the roles of the directories as they pertain to system administration. The top-level
directory structure is shown in Figure 10.8. User home directories are located under /home
but may be further segregated, as shown here as faculty and student subdirectories. Other
directories such as /usr, /etc, and /var contain standardized subdirectories.
10.5.1 Root Partition Directories
We start out our examination with /, which is the topmost point of the Linux file space.
All directories are attached to root by mounting the file systems here. The root directory
should only contain subdirectories, not files. All files would be placed further down the
file space hierarchy. Notice that while we refer to this directory as root, there is also a
/
root
directory. The /root directory is the system administrator’s home directory. The
/root directory is explored below. In the meantime, we will refer to the topmost directory
either as / or the root directory and the system administrator home directory as /root.
420
◾
Linux with Operating System Concepts
The root partition directories will include /bin, /sbin, /etc, and /root. Depending on
how you partitioned your storage space, you might also find /boot and /usr here. We will
make the assumption that /boot is on the root partition while /usr is in a separate partition.
Also, part of the root partition will be directories for /lib, /lost
+
found, /mnt, /opt, and /
tmp. Although /etc should be part of the root partition, we will examine /etc in a separate
subsection because of its importance.
The /bin directory contains binary files (executable programs). It is the primary reposi-
tory of file system commands. For instance, you would find ls, cp, mv, rm, pwd, ln, touch,
chown, chmod, vi, cat, more, mkdir, rmdir, and tar in this directory. You will also find
executables for other common Linux operations in this directory such as echo, sort, date,
ping, traceroute, df, bash, gzip, gunzip, and grep. Interestingly, not all file or basic com-
mands are found in /bin. Those that are not are commonly found in /usr/bin.
The /sbin directory contains other binary files. The main difference between /bin and
/sbin is that /sbin contains programs that are intended for system administration usage.
While many of these programs are accessible by normal users, most users would have
no need to run them. The programs vary greatly in their roles but include disk operation
bin
default
sysconfig
students
marst
zappaf
bearb
foxr
faculty
klinkc
X11R6
bin
local
lib
mail
spool
www
X11
rc.d
boot
dev
etc
home
lib
mnt
proc
root
sbin
tmp
usr
var
lost+found
...
...
FIGURE 10.8
Top-level Linux directory structure. (Adapted from Fox, R.
Information Technology:
An Introduction for Today’s Digital World,
FL: CRC Press, 2013.)
The Linux File System
◾
421
programs (e.g., badblock, fsck, fdisk, mkfs, quotaon), network programs (arp, ifconfig, ip,
iptables), troubleshooting commands (kdump, killall5, mkdumprd), and programs dealing
with system initialization and shutdown such as init, run level, halt, reboot, and shutdown.
Additional system administration programs are found in /usr/sbin.
The /boot directory contains files needed for boot loading the operating system. One of
the most common Linux boot loaders is GRUB (grand unified bootloader). This program
runs shortly after the computer hardware is tested. GRUB lists the available operating sys-
tems and waits for the user to select which operating system to boot to. GRUB then finds
and loads that operating system kernel and the boot process completes by initializing and
running that operating system. GRUB is capable of booting to Linux, BSD Unix, MacOS X,
DOS, and is capable of calling the Windows Boot Manager to boot to Windows NT, Vista,
7 or 8. The GRUB program and support code are all stored in the grub subdirectory of
/boot. In this directory, one of the files is called
device.map
. This file, edited by GRUB
(and also editable by root), contains the mapping information of GRUB device names to
Linux device names.
The /boot directory also contains a program called
vmlinuz
. This is the Linux kernel
in what is known as object format. This program is not directly executable but can be
used by other software to generate executable code. The vmlinuz program actually has a
lengthier name such as
vmlinuz-2.6-32-279.el6.x86_64
based on the specific ver-
sion of Linux installed. There will also be
config
and
System.map
files that match the
extension to vmlinuz (e.g., config-2.6.32-279.el6.x86_64). If you happen to have multiple
kernels available, they will all be stored in this directory with different extended names.
We will explore /boot’s contents in more detail in Chapter 11 when we examine the Linux
boot and initialization process.
In newer Linux distributions, you will also find an
efi
subdirectory of /boot. EFI
stands for extensible firmware interface. This is a new approach to booting that does not
rely on BIOS. One advantage of EFI booting is that through EFI the file space can be made
accessible. In order to use EFI, the boot process bypasses BIOS to execute right from the
EFI firmware.
The /root directory is the home directory for root. If you look at the contents of /root,
you will see that it looks much like any user’s home directory, including, for instance, its
own .bashrc and .bash_profile files. So why is it placed in a separate directory? The main
reasons are security and convenience. The root directory should not be accessible by other
users. Its permissions default to 550 (readable/executable by owner and group only). The
executable access is there so that it can be cd’ed into only by root. We place this restriction
on /root because the system administrator(s) may wish to store confidential information
here, such as passwords generated for new user accounts. For convenience, /root is located
under the root (/) partition. This allows root to log in, unmount /home, perform opera-
tions on /home while still having access to a home directory. If root’s directory was under
/home, /home would always be busy.
The /lib directory is in a way an extension to the /usr directory. /lib will store shared
library files. These are files (usually executable code) that are to be used by multiple pro-
grams. Shared files are of particular use in open source software. The idea is that members
422
◾
Linux with Operating System Concepts
of the open source community utilize other code as much as possible when writing new
applications. This simplifies everyone’s efforts. In newer Linux systems, there are two lib
directories, one for older, 32-bit software (/lib) and one for 64-bit software (/lib64).
The /lost
+
found directory will hopefully always be empty. Its role is to store files that were
found to be damaged in a system that did not go through the proper shutdown process. This
might be the case when there was a sudden system failure or power outage. Upon rebooting
the system, Linux runs a program called
fsck
which checks the integrity of the file systems.
Any corrupted files are moved into /lost
+
found. So, if /lost
+
found is empty, then the file sys-
tems are currently corruption free. If files are found here, it does not necessarily mean that
files are inaccessible or that data have been lost, although that certainly could be the case.
The /tmp directory is a directory for temporary files created by running software. As
software may not have access to its own file space, the /tmp directory is made available.
Interestingly, this directory is writable by world. As such, a system administrator may wish
to place /tmp in its own partition so that it does not constitute a security problem with the
rest of the operating system. The /tmp directory is divided up into subdirectories for dif-
ferent processes and different users. Largely what you find in these directories are domain
sockets. Upon a reboot, anything previously in /tmp will be gone as a new image is created.
The /mnt directory is a mount point that system administrators can use to temporarily
mount partitions. This would not be a permanent mount point but instead often used for
quick mount and umount operations, such as to test the availability of a remote file system,
or to perform some copy or move operation and then unmount the partition.
The directory /opt is available to install third-party software. In essence, if software is
not part of the distribution, it is intended to be installed in /opt. This does not necessarily
mean that installation programs will put it in /opt or that a system administrator must
use /opt. It is also not necessarily straightforward identifying if a software package is part
of the distribution or third party. When software is not installed in /opt, it will instead usu-
ally be placed under /usr/local.
10.5.2 /dev, /proc, and /sys
We group these three directories together because they are both
virtual
file systems. By
virtual, we mean that they do not exist in storage space but instead are located in memory.
You will find these three devices in the /etc/fstab file to be mounted at system initialization
time but they do not appear when you use the df command. You would see the file systems
of proc and sysfs when you use
df –a
.
The /dev directory stores the devices connected to the computer. These are mostly input,
output, and storage devices, although there are exceptions to that statement. We already
explored many of the devices found in /dev (Chapter 3 and earlier in this chapter). Now
that you have read through the earlier parts of this chapter, hopefully you have a bet-
ter understanding of concepts such as character and block devices and the role of sda1,
sda2, sda3 (for SATA hard drives), hda1, hda2, hda3 (for IDE hard drives), and so on. You
will also find symbolic links to other locations in the file space or to devices in /dev. For
instance, the device
core
is a link to /proc/kcore and the device
fd
is a link to /proc/self/
fd while devices such as
dvd
and
dvdrw
are links to
sr0
.
The Linux File System
◾
423
The lp devices are printers. The loop devices are used to connect the file space to specific
files as stored on a block device. This becomes necessary for special types of block devices
such as optical drives and floppy disks.
Another collection of devices go by the name ram0, ram1, and so on. These are used
as
Do'stlaringiz bilan baham: |