Linux administrator Manual (2)

Source: Internet
Author: User

This chapter describes the important part of the standard Linux directory tree, which is based on the FSSTND File System Standard. This section describes how to divide a directory tree into several separated file systems based on different purposes and given requirements. Other methods are also described.

Background

This chapter is loosely based on the Linux File System Standard FSSTND version 1.2 (see [Qui95]) and intends to establish a standard for how to organize the Linux directory tree. Such a standard is easy to write or port (port ?) The advantages of Linux software and Management of Linux systems, because everything will be in their ordinary place. This standard does not have the authority to force everyone to follow, but it has the most support for Linux distributions. If there is no special reason, it is not a good idea to follow FSSTND. FSSTND is intended to comply with Unix traditions and current trends, making it easier for people familiar with other Unix systems to accept Linux systems (and vice versa ).

This chapter is not as detailed as FSSTND. A system administrator should read FSSTND for full understanding.

This chapter does not detail all documents. The intention is not to describe each file, but to give an overview of the system from the perspective of the file system. More information about each file is stored in this manual or elsewhere on the man page.

The full directory tree can be divided into small parts. Each part can be stored on its own disk or partition to accommodate the disk capacity and be easily backed up and managed by other systems. The main parts are the root,/usr,/var, And/home file systems. Each part has a different purpose. The directory tree has been designed to work well on the network of Linux machines. Some parts of the file system can be shared through read-only devices (such as CDROM) or NFS networks.

The following describes the tasks in different parts of the directory tree.

Each machine has a root file system (usually on a local disk, or on a ramdisk or network disk), which contains the necessary files for system guidance and enabling other file systems to mount, the root file system should have enough content in a single user State. Tools such as repair of damaged systems and Backup Recovery should also be included.

The/usr file system contains all commands, libraries, man pages, and other unchanged files required in general operations. /Usr should have no specific files for the given machine, and should not have files to be modified in general use. This allows the files in the file system to be shared over the network, which is more effective because it saves disk space (/usr can easily be several hundred megabytes ), and easy to manage (only the master/usr needs to be changed when upgrading the application, without changing each machine). Even if the file system is on a local disk, it can be read-only mounted, to reduce the damage to the file system when the system crashes.

The/var file system contains changed files, such as spool directories (for mail, news, printers, etc.), log files, formatted manual pages, and temporary files. Traditionally, everything in/var was stored somewhere in/usr, but it is impossible for/usr to be read-only.

/Home file system contains the user's home directory, that is, all the actual data on the system. Assigning home directories to your own directory tree or file system is easy to back up. Other parts often do not have to be backed up, at least do not have to be backed up frequently (they are rarely changed ). A large/home may be divided into several file systems. You need to add a level-1 name under/home, such as/home/students and/home/staff.

Although different parts are called file systems above, they do not have to be truly separated file systems. If the system is a small single-user system and users want to simplify it, they can easily put it in a file system. The directory tree can also be distributed to different file systems based on the disk capacity and the space to be allocated for different purposes. It is important to use the standard name, even if/var and/usr are in the same partition, the name/usr/lib/libc. a And/var/adm/messages must work. For example, move the file under/var to/usr/var and connect/var as the symbol of/usr/var.

The Unix file structure groups files based on the purpose, that is, all commands are in one place, all data is in another place, and all documents are in another place. Another method is to group files according to the program, that is, all Emacs files are in one directory, all TeX files are in another directory, and so on. The problem with the latter method is that files are difficult to share (program directories often contain static and dynamic files that can be shared at the same time ), sometimes it is difficult to find (for example, it is extremely difficult for man programs to find man pages in a large number ).

Root file system

Generally, the root file system should be relatively small, because including strict files and a small, infrequently changed file system is not prone to damage. A corrupted root file system generally means that this risk should not be taken unless the system cannot be booted using a specific method (such as from a floppy disk.

The root directory generally does not contain any files, except for possible standard system boot images, which are usually called/vmlinuz. All other files are in the subdirectory of the root file system.

/Bin
Commands required for boot or commands that may be used by common users (possibly after boot ).

/Sbin
Similar to/bin, but not for common users, although it can be used if necessary and allowed.

/Etc
Configuration file of a specific machine.

/Root
Root user's home directory.

/Lib
Shared libraries required by programs on the root file system.

/Lib/modules
The core can load modules, especially those needed to boot when restoring damaged systems (such as network and file system drivers ).

/Dev
Device File.

/Tmp
Temporary File. Programs running after boot should use/var/tmp instead of/tmp, because the former may be on a disk with more space.

/Boot
The file used by the bootstrap loader, such as LILO. The core image is often here, not in the root directory. If there are many core images, this directory may become very large and it may be better to use a separate file system. Another reason is to ensure that the core image must be in the first 1024 cylinder of the IDE hard disk.

/Mnt
System Administrator temporary mount Installation Point. The program does not automatically support installation to/mnt. /Mnt can be divided into sub-directories (for example,/mnt/dosa may be a soft drive using the MSDOS file system, while/mnt/exta may be a soft drive using the ext2 File System ).

/Proc,/usr,/var,/home
Other File System installation points.

/Etc directory
The/etc directory contains many files. The following describes some of them. Others you should know which program they belong to and read the man page of the program. Many network configuration files are also in/etc, which are described in the network management guide.

/Etc/rc or/etc/rc. d or/etc/rc. d
Start or change the scripts or scripts directory that runs at the running level. For more information, see the init chapter.

/Etc/passwd
User database, where the domain provides the user name, real name, Home Directory, encrypted password, and other user information. For the format, see the man page of passwd.

/Etc/fdprm
Floppy Disk parameter table. Different floppy disk formats are described. Set with setfdprm. For more information, see the man page of setfdprm.

/Etc/fstab
The mount-a command (in/etc/rc or equivalent Startup File) automatically mounts the list of file systems at startup. In Linux, information about the swap zone enabled with swapon-a is also included. See section 4.8.5 and the mount man page.

/Etc/group
Similar to/etc/passwd, but it does not indicate the user but the group. See the man page of the group.

/Etc/inittab
Init configuration file.

/Etc/issue
Getty output before the logon prompt. It usually includes a short description or welcome information of the system. The content is determined by the system administrator.

/Etc/magic
File configuration file. It contains descriptions of different file formats. Based on this, the file guesses the file type. See the man pages of magic and file.

/Etc/motd
Message Of The Day, which is automatically output after successful logon. The content is determined by the system administrator. It is often used for notification information, such as warning about the scheduled shutdown time.

/Etc/mtab
List of currently installed file systems. It is initialized by scripts and automatically updated by the mount command. This command is used when you need a list of currently installed file systems, such as the df command.

/Etc/shadow
The shadow password file on the system where the shadow password software is installed. The shadow password file moves the encrypted password in the/etc/passwd file to the/etc/shadow file, which is only readable to the root user. This makes password cracking more difficult.

/Etc/login. defs
The configuration file of the login command.

/Etc/printcap
Similar to/etc/termcap, but for printers. Different syntaxes.

/Etc/profile,/etc/csh. login,/etc/csh. cshrc
Files executed by Bourne or C shells at login or startup. This allows the system administrator to create a global default environment for all users. For various shells, see the man page.

/Etc/securetty
Confirm the security terminal, that is, the terminal that allows root login. Generally, only the virtual console is listed. In this way, it is impossible (at least difficult) to break into the system through a modem or network and obtain super user privileges.

/Etc/shells
List trusted shells. The chsh command allows you to change the logon shell within the range specified in this file. The ftpd service process that provides an FTP service on a machine checks whether the user's shell is listed in the/etc/shells file. If not, the user is not allowed to log on.

/Etc/termcap
Terminal performance database. Describes the "Escape Sequence" control used by different terminals. When writing a program, the escape sequence is not output directly (this can only work on terminals of a specific brand), but the correct sequence of the work to be done is searched from/etc/termcap. In this way, most programs can run on most terminals. See the man pages of termcap, curs_termcap, and terminfo.

/Dev directory
The/dev directory contains the device files of all devices. Device Files are named according to specific conventions, which are described in the device list (see [Anv]). The device file is generated during installation and can be described in/dev/MAKEDEV later. /Dev/MAKEDEV. local is the description document written by the system administrator for the local device file (or connection) (for example, some non-standard device drivers are not part of the standard MAKEDEV ).

/Usr File System
The/usr file system is often large because all programs are installed here. All files in/usr are generally from Linux distribution. Locally installed programs and other things are under/usr/local. In this way, you do not need to re-install all programs when upgrading the new system or the new distribution. Some subdirectories of/usr are listed below (some less important directories are omitted. For more information, see FSSTND ).

/Usr/X11R6
All files in the X Window System. To simplify the development and installation of X, X files are not integrated into the system. X is similar to/usr in/usr/X11R6.

/Usr/X386
Similar to/usr/X11R6, but for X11 Release 5.

/Usr/bin
Almost all user commands. Some commands are in/bin or/usr/local/bin.

/Usr/sbin
Unnecessary system management commands for the root file system, such as most service programs.

/Usr/man,/usr/info,/usr/doc
The manual page, the GNU information document, and various other documents.

/Usr/include
C Programming Language header file. For consistency, this should be in/usr/lib, but this name is traditionally supported.

/Usr/lib
Unchanged data files of programs or subsystems, including some site-wide configuration files. The name lib comes from the library. The original programming inventory is in/usr/lib.

/Usr/local
Install the software and other files locally.

/Var file system
/Var includes the data to be changed during normal system running. Each system is specific, that is, it is not shared with other computers through the network.

/Var/catman
The cache of man pages when formatting is required. The source file of the man page usually exists in/usr/man *. Some man pages may have pre-formatted versions and are stored in/usr/man/cat. Other man pages need to be formatted when they are viewed for the first time. The formatted version exists in/var/man, so that other people do not have to wait for formatting when looking at the same page. (/Var/catman is often cleared, just like clearing a temporary directory .)

/Var/lib
The file to be changed when the system is running normally.

/Var/local
Variable data of programs installed in/usr/local (that is, programs installed by the system administrator ). Note: if necessary, other/var directories, such as/var/lock, will be used even for locally installed programs.

/Var/lock
Lock the file. Many programs follow the Convention of generating a locked file in/var/lock to support their use of a specific device or file. Other programs will not try to use this device or file when they notice this locked file.

/Var/log
Log Files of various programs, especially login (/var/log/wtmp log all logon and logout to the system) and syslog (/var/log/messages stores all core and system program information. Files in/var/log often grow uncertain and should be cleared regularly.

/Var/run
The system information file that is valid before the next boot. For example,/var/run/utmp contains the information of the user currently logged on.

/Var/spool
Mail, news, print the working directory of the queue and other queues. Each different spool has its own sub-directories under/var/spool. For example, the user's email address is in/var/spool/mail.

/Var/tmp
Larger than/tmp, or temporary files that require a long period of time. (Although the system administrator may not allow/var/tmp to have very old files .)

/Proc file system
The/proc file system is a false file system. It does not exist on a disk. Instead, the core is generated in the memory. Used to provide information about the system (originally about processes, hence the name ). The following describes some of the most important files and directories. The/proc file system is described in more detail on the proc man page.

/Proc/1
The information directory of process 1. Each process has a directory named process number under/proc.

/Proc/cpuinfo
Processor information, such as type, manufacturer, model, and performance.

/Proc/devices
List of device drivers of the core configurations currently running.

/Proc/dma
Displays the currently used DMA channel.

/Proc/filesystems
Core configuration file system.

/Proc/interrupts
Displays the interruption of use, and how to handle the each there have been.

/Proc/ioports
The currently used I/O port.

/Proc/kcore
System physical memory image. It is identical to the physical memory size, but does not actually occupy so much memory; it is generated on the fly as programs access it. (Remember: Unless you copy it to somewhere, nothing in/proc occupies any disk space .)

/Proc/kmsg
Core Output Message. Also sent to syslog.

/Proc/ksyms
Core symbol table.

/Proc/loadavg
System "average load"; three meaningless indicators indicate the current workload of the system.

/Proc/meminfo
Memory usage information, including physical memory and swap.

/Proc/modules
Which core modules are currently loaded.

/Proc/net
Network Protocol status information.

/Proc/self
Symbolic connection to the process directory of the program to view/proc. When two processes view/proc, the connection is different. This allows the program to obtain its own process directory.

/Proc/stat
Different States of the system, such as the number of page faults since the system was booted.

/Proc/uptime
The duration of system startup.

/Proc/version
Core version.

Note that all the above files provide readable text files, which may sometimes be difficult to read. Many commands have been formatted to make it easier to read. For example, the free program reads/proc/meminfo and converts the number of bytes to kilobytes (and adds some information ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.