Note that each of these commands can be used with pattern-matching strings known as
$ rm abc*
Linux shells recognize many types of filenaming wildcards, but this is different from the capabilities of Linux commands supporting the use of more complex expressions. You learn more about using wildcards in Chapter 11, 'Automating Tasks.'
Learn more about using expressions by reading the ex
or grep
manual pages.
Working with Compressed Files
Another file management operation is compression and decompression of files, or the creation, listing, and expansion of file and directory archives. Linux distributions usually include several compression utilities you can use to create, compress, expand, or list the contents of compressed files and archives. These commands include the following:
> bunzip2
— Expands a compressed file
> bzip2
— Compresses or expands files and directories
> gunzip
— Expands a compressed file
> gzip
— Compresses or expands files and directories
> shar file
— Creates a shell archive of files
> 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 /lib
or /usr/lib
directories. Nearly all the other applications on your system are
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
> 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