Linux Bible. Christopher Negus

Чтение книги онлайн.

Читать онлайн книгу Linux Bible - Christopher Negus страница 48

Linux Bible - Christopher Negus

Скачать книгу

by applications in /bin and /sbin to boot the system. /mnt A common mount point for many devices before it was supplanted by the standard /media directory. Some bootable Linux systems still use this directory to mount hard disk partitions and remote filesystems. Many people still use this directory to temporarily mount local or remote filesystems, which are not mounted permanently. /misc A directory sometimes used to automount filesystems upon request. /opt Directory structure available to store add-on application software. /proc Contains information about system resources. /root Represents the root user's home directory. The home directory for root does not reside beneath /home for security reasons. /sbin Contains administrative commands and daemon processes. /sys Contains parameters for such things as tuning block storage and managing cgroups. /tmp Contains temporary files used by applications. /usr Contains user documentation, games, graphical files (X11), libraries (lib), and a variety of other commands and files that are not needed during the boot process. The /usr directory is meant for files that don't change after installation (in theory, /usr could be mounted read-only). /var Contains directories of data used by various applications. In particular, this is where you would place files that you share as an FTP server (/var/ftp) or a web server (/var/www). It also contains all system log files (/var/log) and spool files in /var/spool (such as mail, cups, and news). The /var directory contains directories and files that are meant to change often. On server computers, it is common to create the /var directory as a separate filesystem, using a filesystem type that can be easily expanded.

      The filesystems in the DOS or Microsoft Windows operating systems differ from Linux's file structure, as the sidebar “Linux Filesystems versus Windows-Based Filesystems” explains.

      Linux Filesystems versus Windows-Based Filesystems

      Although similar in many ways, the Linux filesystem has some striking differences when compared to filesystems used in MS-DOS and Windows operating systems. Here are a few of these differences:

       In MS-DOS and Windows filesystems, drive letters represent different storage devices. In Linux, all storage devices are connected to the filesystem hierarchy. So, the fact that all of /usr may be on a separate hard disk or that /mnt/remote1 is a filesystem from another computer is invisible to the user.

       Slashes, rather than backslashes, are used to separate directory names in Linux. So C:\home\joe in a Microsoft system is /home/joe in a Linux system.

       Filenames almost always have suffixes in DOS (such as .txt for text files or .docx for word-processing files). Although at times you can use that convention in Linux, three-character suffixes have no required meaning in Linux. They can be useful for identifying a file type. Many Linux applications and desktop environments use file suffixes to determine the contents of a file. In Linux, however, DOS command extensions such as .com, .exe, and .bat don't necessarily signify an executable. (Permission flags make Linux files executable.)

       Every file and directory in a Linux system has permissions and ownership associated with it. Security varies among Microsoft systems. Because DOS and Microsoft Windows began as single-user systems, file ownership was not built into those systems when they were designed. Later releases added features such as file and folder attributes to address this problem.

Command Result
cd Changes to another directory
pwd Prints the name of the current (or present) working directory
mkdir Creates a directory
chmod Changes the permission on a file or directory
ls Lists the contents of a directory

      One of the most basic commands that you use from the shell is cd. The cd command can be used with no options (to take you to your home directory) or with full or relative paths. Consider the following commands:

       $ cd /usr/share/ $ pwd /usr/share $ cd doc $ pwd /usr/share/doc $ cd $ pwd /home/chris

      The /usr/share option represents the absolute path to a directory on the system. Because it begins with a slash (/), this path tells the shell to start at the root of the filesystem and take you to the share directory that exists in the usr directory. The doc option to the cd command looks for a directory called doc that is relative to the current directory. So that command made /usr/share/doc your current directory.

      After that, by typing cd alone, you are returned to your home directory. If you ever wonder where you are in the filesystem, the pwd command can help you. Here are a few other interesting cd command options:

       $ cd ~ $ pwd /home/chris $ cd ~/Music $ pwd /home/chris/Music $ cd ../../../usr $ pwd /usr

      The tilde (~) represents your home

Скачать книгу