Выбрать главу

 O'Reilly Network: http://www.oreillynet.com/

4.3. Managing Files

A large part of system administration involves dealing with files and directories: creating directories, copying files, moving files and directories around, and deleting them. Fedora provides a powerful set of tools for managing files from the shell prompt as well as graphically.

4.3.1. How Do I Do That?

Linux, like most modern operating systems, uses a tree-like hierarchy to store and organize files. To manage files effectively, extend the hierarchy to organize your data.

4.3.1.1. Understanding Linux directory names

Fedora's master directory (or folder , as it would be referred to by other operating systems) is called the root directory ; it may contain files and directories. Each of those directories may in turn contain other files and directories.

For each user, one directory is designated as the home directory , and that is where that user stores her personal files. Additionally, each process (a running copy of a program) has a current working directory on the system, which is the directory that it accesses by default unless another directory is explicitly specified.

The root directory is always the same system-wide; the home directory is consistent for a particular user, but varies from user to user; and the current working directory is unique to each process and can be changed anytime.

A pathname specifies how to find a file in the file hierarchy. There are three different pathname schemes that can be used, based on the three different starting points (root, home, and current working directory); each scheme specifies the path from the selected starting point to the desired file, separating directory names with the forward slash character ( / ). These three schemes are summarized in Table 4-4 .

Table 4-4. Absolute, Relative, and Relative-to-Home pathnames

Scheme First characters of pathname Relative to... Example
Absolute / Root directory /home/chris/book/chapter/one.odt
Relative-to-Home ~ User's home directory ~/book/chapter/one.odt
  ~ chris Home directory of chris ~chris/book/chapter/one.odt
Relative (Anything other than / or ~) Current working directory chapter/one.odt (Assuming that /home/chris/book is the current directory)

The special symbols . (same directory) and .. (parent directory) are useful in pathnames. For example, if your current directory is /home/chris/book , then ../invitation refers to /home/chris/invitation.

4.3.1.2. Key directories

Fedora uses a standard set of directories derived from historical conventions, the Linux Standard Base (LSB) project, and the kernel. Table 4-5 outlines the key directories and their purpose.

Table 4-5. Key directories in Fedora Core

Directory Purpose
/bin Basic binaries (programs) needed to start the system.
/boot Files used during the boot process, including the boot menu and kernel.
/dev This directory contains special files that are actually connections to devices, such as keyboards, mice, modems, printers, sound cards, and so forth. When you read data from a special file or write data to it, you're actually communicating with the associated device.
/etc System configuration files (sometimes regarded as the "home directory for the computer").
/home Users' home directories, for the storage of personal files.
/lib Libraries.
/lost+found A directory used to recover files in the event of filesystem damage. Any file that has been disassociated from its name is placed here during filesystem recovery.
/media External media (floppy disks, USB drives, digital cameras, optical disks) that have been mounted.
/mnt Historical location for mounting storage devices, many of which have now moved to /media.
/opt Optional, add-on software. The definition of add-on software is subjective; if you obtain OpenOffice.org directly from the openoffice.org web site, it will be installed here, but if you install the version distributed with Fedora, it will be installed in /usr/bin.
/proc Per-process status information plus system information.
/root Home directory for the root user (superuser).
/sbin Basic system administration binaries.
/selinux Files for Security Enhanced Linux.
/sys System device information.
/tmp Temporary file storage.
/usr User data (years ago, home directories were also stored in /usr).
/usr/bin The remainder of the standard binaries.
/usr/lib User libraries.
/usr/libexec Programs that are not directly executed by the user but that are executed by another application (e.g., graphics demos for the xscreensaver program)
/usr/local Local files (specific to your system configuration).
/usr/local/bin Local binaries and scripts.
/usr/sbin The remainder of the system administration binaries.
/usr/src Source code for locally built RPM packages and the Linux kernel.
/var Files that change frequently (variable), including databases, print requests, and logfiles.
/var/log Various system logfiles.
/var/spool Files for various queues (spools), such as print queues and file-transfer queues.