► tar
— Creates, expands, or lists the contents of compressed or uncompressed file or directory archives known as tape archives or tarballs
Most of these commands are easy to use. The tar command, however, has a somewhat complex (although capable) set of command-line options and syntax. Even so, you can quickly learn to use tar by remembering a few simple invocations on the command line. For example, to create a compressed archive of a directory, use tar's czf
options like this:
$ tar czf dirname.tgz dirname
The result is a compressed archive (a file ending in .tgz
) of the specified directory (and all files and directories under it). Add the letter v
to the preceding options to view the list of files added during compression and archiving. To list the contents of the compressed archive, substitute the c
option with the letter t, as follows:
$ tar tzf archive
Of course, if many files are in the archive, a better invocation (to easily read or scroll through the output) is the following:
$ tar tzf archive | less
To expand the contents of a compressed archive, use tar's zxf
options, like so:
$ tar zxf archive
The tar
utility decompresses the specified archive and extracts the contents in the current directory.
Use Essential Commands from the /bin
and /sbin
Directories
The /bin
directory (about 5MB if you do a full install) contains essential commands used by the system for running and booting Linux. In general, only the root operator uses the commands in the /sbin
directory. Many (though not all) of these commands are statically linked; which means that these commands do not depend on software libraries residing under the /lib
or /usr/lib
directories. Nearly all the other applications on your system are dynamically linked — meaning that they require external software libraries (also known as shared libraries) to run.
Use and Edit Files in the /etc
Directory
More than 90MB of system configuration files and directories reside under the /etc
directory if you install all the software included with this book. Some major software packages, such as Apache, OpenSSH, and xinetd,
have directories of configuration files under /etc.
Other important system-related configuration files in /etc
include the following:
► fstab
— The file system table is a text file listing each hard drive, CD-ROM, floppy, or other storage device attached to your PC. The table indexes each device's partition information with a place in your Linux file system (directory layout) and lists other options for each device when used with Linux (see Chapter 35, "Managing the File System"). Nearly all entries in fstab can be manipulated by root using the mount
command.)
► inittab
— The system initialization table defines the default runlevel, also known as run-control level or system state . Changes to this file can determine whether your system boots to a graphical or text login, as well as whether dialup remote access is enabled. (You learn about default runlevels in the section "System Services and Runlevels" located in Chapter 11. See the section "Starting X" located in Chapter 3, "Working with GNOME," to learn more about changing inittab to boot to a graphical interface.)
► modprobe.conf
— This configuration file contains directions and options used when loading kernel modules to enable various types of hardware, such as sound, USB, networking, and so on (discussed in the section "Managing Modules" in Chapter 36, "Kernel and Module Management"). The contents of this file are used during boot
time, and the file can be manually edited or automatically updated by Fedora's kudzu
hardware management tool.
► passwd
— The list of users for the system, along with user account information. The contents of this file can be changed by various programs, such as useradd
or chsh.
► printcap
— The system's printer capabilities database (discussed in the section "Overview of Fedora Printing" in Chapter 8, "Printing with Fedora").
► shells
— A list of approved shells (command-line interfaces).
The /etc/sysconfig
directory contains many different hardware and software settings critical to the operation of your Fedora system. Knowing the location and contents of these files can prove helpful if you need to troubleshoot new hardware configurations. The best way to list the contents of /etc/sysconfig
is to use the tree
command, like so:
$ tree -afx /etc/sysconfig
The settings in various files under /etc/sysconfig
(such as firstboot, keyboard, clock,
and so on) are usually created automatically by a related Fedora graphical or console- based configuration utility.
These contents might change dynamically if you use the kudzu
hardware configuration service. The kudzu
service also prompts you at boot time to remove, configure, or ignore a related setting if kudzu
detects new or different hardware (such as a new USB keyboard, network card, or monitor). The kudzu
service creates a file called hwconf
that contains a hardware profile of your PC's current state. Note that if kudzu
is not enabled or running, you can use device-specific configuration utilities such as system-config-keyboard
, or you can manually edit configuration files.
Information about the type of keyboard attached to the PC, for example, is contained in the file /etc/sysconfig/keyboard
:
KEYBOARDTYPE="pc"
KEYTABLE="uk"
Here the keyboard in use is the U.K. layout, but if you are in the United States, you will likely see this:
KEYBOARDTYPE="pc"
KEYTABLE="us"
CAUTION
If you are new to Linux, the system-config-keyboard
client is the best tool to use to configure a keyboard. You should manually edit system hardware configuration files used by graphical management clients only as a last resort.
Protect the Contents of User Directories — /home
The most important data on a Linux system resides in the user's directories, found under the /home
directory. Segregating the system and user data can be helpful in preventing data loss and making the process of backing up easier. For example, having user data reside on a separate file system or mounted from a remote computer on the network might help shield users from data loss in the event of a system hardware failure.
Use the Contents of the /proc
Directory to Interact with the Kernel
The content of the /proc
directory is created from memory and exists only while Linux is running. This directory contains special "files" that either extract information from or send information to the kernel. Many Linux utilities extract information from dynamically created directories and files under this directory, also known as a virtual file system . For example, the free command obtains its information from a file named meminfo:
Читать дальше