Книга: Fedora™ Unleashed, 2008 edition

Navigating Through the File System

Navigating Through the File System

Use the cd command to navigate through the Fedora file system. This command is generally used with a specific directory location or pathname, like this:

$ cd /usr/share/doc

Under Fedora, the cd command can also be used with several shortcuts. For example, to quickly move up to the parent (higher-level) directory, use the cd command like this:

$ cd ..

To return to one's home directory from anywhere in the Linux file system, use the cd command like this:

$ cd

You can also use the $HOME shell environment variable to accomplish the same thing. Type this command and press Enter to return to your home directory:

$ cd $HOME

You can accomplish the same thing by using the tilde (~) like this:

$ cd ~

CAUTION

Don't forget the pwd command to remind you where you are within the file system!

Another important command to use is the ls command, which lists the contents of the current directory. It's commonly used by itself, but a number of options (or switches) available for ls give you more information. For instance, the following command returns a listing of all the files and directories within the current directory, including any hidden files (denoted by a . prefix) as well as a full listing, so it will include details such as the permissions, owner and group, size, and last modified time and date:

$ ls -al

You can also issue the following command:

$ ls -R

This command scans and lists all the contents of the subdirectories of the current directory. This might be a lot of information, so you might want to redirect the output to a text file so that you can browse through it at your leisure by using the following:

$ ls alR > listing.txt

Table 4.1 shows some of the standard directories found in Fedora.

TABLE 4.1 Basic Linux Directories

Name Description
/ The root directory
/bin Essential commands
/boot Boot loader files, Linux kernel
/dev Device files
/etc System configuration files
/home User home directories
/initrd Initial RAM disk boot support (used during boot time)
/lib Shared libraries, kernel modules
/lost+found Directory for recovered files (if found after a file system check)
/media Mount point for removable media, such as DVDs and floppy disks
/mnt Usual mount point for local, remote file systems
/opt Add-on software packages
/proc Kernel information, process control
/root Super user (root home)
/sbin System commands (mostly root only)
/selinux Holds the data for SELinux, the security component of Fedora
/sys Real-time information on devices used by the kernel
/tmp Temporary files
/usr Secondary software file hierarchy
/var Variable data (such as logs); spooled files

Some of the important directories in Table 4.1, such as those containing user and root commands or system configuration files, are discussed in the following sections. You use and edit files under these directories when you use Fedora.

Linux also includes a number of GNU commands you can use to search the file system. These include the following:

whereis command—Returns the location of the command and its man page.

whatis command — Returns a one-line synopsis from the command's man page.

locate file command — Returns locations of all matching file(s); an extremely fast method of searching your system because locate searches a database containing an index of all files on your system. However, this database (about 4MB in size and named slocate.db, under the /var/lib/slocate directory) is built daily at 4:20 a.m. by default, and does not contain pathnames to files created during the workday or in the evening. If you do not keep your machine on constantly, you can run the updatedb command as the super user to manually start the building of the database.

apropos subject command — Returns a list of commands related to subject.

Оглавление книги


Генерация: 0.041. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз