Structure and usage of folders in linux (detailed)
Structure and usage of folders in linux:
/Bin: binary executable command.
/Dev: special file of the device.
/Etc: system management and configuration files.
/Etc/rc. d: configuration file and script to be started.
/Home: the base point of the user's home directory. For example, if the user's home directory is/home/user, you can use ~ User.
/Lib: The standard programming library, also known as the dynamic link shared library, works similar to. dll files in windows.
/Sbin: System Management command, which stores the management program used by the system administrator.
/Tmp: A Public temporary file storage point.
/Root: main directory of the system administrator.
/Mnt: The system provides this directory for users to temporarily Mount other file systems.
/Lost + found: This directory is usually empty, and the system shuts down abnormally, leaving the "Homeless" file here.
/Proc: virtual directory, which is the system memory ing. You can directly access this directory to obtain system information.
/Var: overflow areas of some large files, such as log files of various services.
/Usr: the largest directory. Almost all the applications and files to be used are in this directory. Including:
/Usr/x11r6: directory for storing x Windows.
/Usr/bin: a large number of applications.
/Usr/sbin: hyperuser management programs.
/Usr/doc: linux document.
/Usr/include: header files required for developing and compiling applications in linux.
/Usr/lib: common dynamic link library and software package configuration files.
/Usr/man: help document.
/Usr/src: source code. The source code of the linux kernel is stored in/usr/src/linux.
/Usr/local/bin: commands added locally.
/Usr/local/lib: added local root file system.
Generally, the space occupied by the root file system should be relatively small, because most of the files do not need to be changed frequently, it also includes strict files and a small, infrequently changed file system that is not easily damaged. Except for a possible/vmlinuz standard system boot image, the root directory generally does not contain any files. All other files are in the subdirectory of the root file system.
1./bin directory
The/bin directory contains the commands required for boot or Common commands (possibly after boot ). These command lines are executable programs of binary files (bin is short for binary). Most of them are important system files in the system.
2./sbin directory
The/sbin directory is similar to/bin and is also used to store binary files. Most of these files are the basic system programs used by the system administrator. Although common users can use them when necessary, they are generally not used by common users.
3./etc directory
The/etc directory stores various system configuration files, including user information files/etc/passwd and system initialization files/etc/rc. Linux runs properly only through these files.
4./root directory
The/root directory is the root user directory.
5./lib directory
The/lib directory is the shared library required by the Program on the root file system. It stores the shared files required by the root file system program. These files contain code that can be shared by many programs, so that each program contains copies of the same subroutine, so that the executable files can be smaller and save space.
6./lib/modules directory
The/lib/modules directory contains the system core which can be loaded with various modules, especially those required to re-boot the system (such as network and file system drivers) when restoring damaged systems ).
7./dev directory
The/dev directory stores device files, that is, device drivers. You can use these files to access external devices. For example, you can access the mouse input by accessing/dev/mouse, just like accessing other files.
8./tmp directory
The/tmp directory stores information and data generated by the program during runtime. However, after boot, it is best to use/var/tmp to replace/tmp for running programs, because the former may have a larger disk space.
9./boot directory
The/boot directory stores the files used by the bootstrap loader, such as lilo. The core images are often stored here, rather than in the root directory. However, if there are many core images, this directory may become very large, and it would be better to use a separate file system. Note that the core image must be in the first 1024 cylinder of the ide hard disk.
10./mnt directory
The/mnt directory is the installation point for the temporary installation (mount) File System of the system administrator. The program does not automatically support installation to/mnt. /Mnt can be divided into many 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, /mnt/cdrom optical drive and so on.
11./proc,/usr,/var,/home Directory
Other File System installation points.
The directory tree can be divided into small parts, each of which can be on its own disk or partition. The main parts are the root,/usr,/var, And/home file systems. Each part has a different purpose.
Each machine has a root file system, which contains all the files necessary for system guidance and enabling other file systems to mount. The root file system should have enough content required for 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 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 file system damage 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. 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.
The following details:
/Etc File System
The/etc directory contains various system configuration files, which are described below. 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.
1./etc/rc or/etc/rc. d or/etc/rc ?. D: The Directory of scripts or scripts that start or change at the running level.
2./etc/passwd: user database, where the domain provides the user name, real name, user start directory, encrypted password, and other user information.
3./etc/fdprm: floppy disk parameter table to describe different floppy disk formats. Setfdprm can be used for setting. For more information, see the Help page of setfdprm.
4./etc/fstab: Specifies the list of file systems to be automatically installed at startup. It also includes information about the swap zone enabled with swapon-.
5./etc/group: similar to/etc/passwd, but it does not indicate user information but group information. Including various data of the group.
6./etc/inittab: init configuration file.
7./etc/issue: including the user's output information before the logon prompt. It usually includes a short description or welcome information of the system. The specific content is determined by the system administrator.
8./etc/magic: "file" configuration file. It contains different file formats. "file" is used to guess the file type.
9./etc/motd: motd is short for message of the day, which is automatically output after the user logs on successfully. The content is determined by the system administrator.
It is often used for notification information, such as warning about the scheduled shutdown time.
10./etc/mtab: List of currently installed file systems. It is initialized by the script (scrui) and automatically updated by the mount command. Use (such as the df command) when you need a list of currently installed file systems ).
11./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 deciphering more difficult and increases the security of the system.
12./etc/login. defs: configuration file of the login command.
13./etc/printcap: similar to/etc/termcap, but for printers. Different syntaxes.
14./etc/profile,/etc/csh. login,/etc/csh. cshrc: files that are logged on or executed by bourne or cshells at startup. This allows the system administrator to create a global default environment for all users.
15./etc/securetty: confirm the security terminal, that is, the terminal that allows the Super User (root) to log on. Generally, only the virtual console is listed, so that it is impossible (at least difficult) to break into the system through a modem or network and obtain super user privileges.
16./etc/shells: list the shells that can be used. The chsh command allows you to change the logon shell within the specified range of 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.
17./etc/termcap: terminal performance database. Describes the "Escape Sequence" control mechanism 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.
/Dev File System
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. The device files are generated by the system 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 ). The following describes some common files in/dev.
1./dev/console: the system console, that is, the monitor directly connected to the system.
2./dev/hd: ide Hard Drive Interface. For example,/dev/hda indicates the first hard disk and had1 indicates the first partition of/dev/hda. If there are other hard disks in the system, they are/dev/hdb,/dev/hdc ,......; if multiple partitions exist, they are hda1 and hda2 ......
3./dev/sd: scsi disk driver interface. If the system has a scsi hard disk, it will not access/dev/had, but/dev/sda.
4./dev/fd: Driver of the software drive device. For example,/dev/fd0 indicates the first floppy disk of the system, that is, disk a./dev/fd1 indicates the second floppy disk ,...... the/dev/fd1 h1440 indicates accessing the 4.5 high-density disk in drive 1.
5./dev/st: scsi tape drive driver.
6./dev/tty: provides support for the virtual console. For example,/dev/tty1 indicates the first virtual console of the system, and/dev/tty2 indicates the second virtual console of the system.
7./dev/pty: supports remote logon to pseudo terminals. /Dev/pty is required for telnet logon.
8./dev/ttys: computer serial interface, which is the "com1" port for dos.
9./dev/cua: computer serial interface, used with the modem.
10./dev/null: "black hole". All information written to this device will disappear. For example, to hide the output information on the screen, you only need to input the output information to/dev/null.
/Usr File System
/Usr is a very important directory. Usually this file system is large because all programs are installed here. All files in/usr are generally from the linux release. 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 new release. Many contents in the/usr directory are optional, but these functions make the user use the system more effective. /Usr can accommodate many large software packages and their configuration files. Some important directories are listed below (some less important directories are omitted ).
1./usr/x11r6: contains all executable programs, configuration files, and support files of the x window System. To simplify the development and installation of x, x files are not integrated into the system. The x window System is a powerful graphic environment that provides a large number of graphic tool programs. If you are familiar with microsoft windows, you will not feel helpless about the x window System.
2./usr/x386: similar to/usr/x11r6, but it is dedicated to x 11 release 5.
3./usr/bin: Collects almost all user commands, which are the system software libraries. Some other commands are in/bin or/usr/local/bin.
4./usr/sbin: contains unnecessary system management commands for the root file system, such as most service programs.
5./usr/man,/usr/info,/usr/doc: these directories contain all the manual pages, gnu information documents, and various other document files. Each "section" of an online manual has two sub-directories. For example,/usr/man/man1 contains the source code of section 1 of the online manual (the original file is not formatted), and/usr/man/cat1 contains the formatted content of section 1. The online manual is divided into nine sections: Internal commands, system calls, library functions, devices, file formats, games, macro software packages, system management, and core programs.
6./usr/include: contains the header file of c language. These files end with. h and are used to describe the data structures, subprocesses, and constants used in c language programs. In order to maintain consistency, this should be put under/usr/lib, but this name has always been used.
7./usr/lib: Contains unchanged data files of programs or subsystems, including some site-wide configuration files. The name lib comes from the library. The original library for programming also exists in/usr/lib. When you compile a program, the program will be connected to the library. Many programs store configuration files.
8./usr/local: local software and other files are stored here. This is similar to/usr. You may find some large software packages, such as tex and emacs.
/Var file system
/Var contains the data to be changed during normal operation of the system. The directory size of the data is usually changed or expanded. Some Contents in the original/var directory are in/usr, but to keep the/usr directory relatively stable, put those directories that need to be changed frequently in/var. Each system is specific, that is, it is not shared with other computers through the network. Some important directories are listed below (some less important directories are omitted ).
1./var/catman: contains the formatted help (man) page. The source files on the help page are usually stored in/usr/man/catman. Some man pages may have pre-formatted versions and are stored in/usr/man/cat. Other man pages must be formatted when they are viewed for the first time. The formatted version exists in/var/man, so that others do not have to wait for formatting when looking at the same page. (/Var/catman is often cleared, just like clearing a temporary directory .)
2./var/lib: stores the files to be changed when the system is running normally.
3./var/local: stores 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.
4./var/lock: lock the file. Many programs follow the Convention of generating a locked file in/var/lock to support the use of a specific device or file. Other programs will no longer use this device or file when they notice this locked file.
5. /var/log: log files of various programs, especially login (/var/log/wtmplog records all logon and logout to the system) and syslog (/var/log/messages records store all core and system program information ). Files in/var/log often grow uncertain and should be cleared regularly.
6./var/run: Save the system information files that are valid before the next system boot. For example, the/var/run/utmp package contains the information of the user currently logged on.
7./var/spool: directory of the "spool" program, such as the directory where mail, news, print queue, and other queues work. Each different spool has its own sub-directories under/var/spool. For example, users' mailboxes are stored in/var/spool/mail.
8./var/tmp: a temporary file that is larger than/tmp or requires a long time. Note that the system administrator may not allow/var/tmp to have very old files.
/Proc file system
The/proc file system is a pseudo file system, that is, it is a directory that actually does not exist, so this is a very special directory. It does not exist on a disk, but is generated by the core in the memory. This directory is used to provide information about the system. The following describes some of the most important files and directories (/proc file systems are described in more detail on the proc man page ).
1./proc/x: The information directory of process x, which indicates the ID of the process. Each process has a directory named its own process number under/proc.
2./proc/cpuinfo: stores information about the cpu, such as the cpu type, manufacturer, model, and performance.
3./proc/devices: List of device drivers with core configurations currently running.
4./proc/dma: displays the currently used dma channel.
5./proc/filesystems: File System Information of the core configuration.
6./proc/interrupts: displays the information of the interrupted and occupied users, and the number of occupied users.
7./proc/ioports: current I/o port.
8./proc/kcore: physical memory image of the system. It is identical to the physical memory size, but it does not actually occupy so much memory; it is created only when the program accesses it. (Note: Unless you copy it to somewhere, nothing in/proc occupies any disk space .)
9./proc/kmsg: Core Output Message. It will also be sent to syslog.
10./proc/ksyms: Core symbol table.
11./proc/loadavg: System "average load"; three meaningless indicators indicate the current workload of the system.
12./proc/meminfo: Various memory usage information, including physical memory and swap partition (swap ).
13./proc/modules: stores information about the core modules currently loaded.
14./proc/net: network protocol status information.
15./proc/self: stores the symbolic connection to the process directory of the program you want to view/proc. When two processes view/proc, this will be a different connection. This allows the program to obtain its own process directory.
16./proc/stat: different states of the system, such as the number of page errors after the system starts.
17./proc/uptime: the duration of system startup.
18./proc/version: core version.
/Usr/local is generally the directory where you install the software. This directory is equivalent to the programefiles directory in windows.
The/opt directory is the installation directory of some large software, or the installation directory of some service programs.
For example, you can install the test version firefox in the/opt/firefox_beta directory, the/opt/firefox_beta directory contains all the files, libraries, and data required to run firefox. To delete firefox, you only need to delete the/opt/firefox_beta Directory, which is very simple.
/Usr/local
This mainly stores software that is manually installed, that is, software that is not installed through the "new" or apt-get. It has a similar directory structure as the/usr directory. Let the Software Package Manager manage the/usr directory, and put the custom script (scripts) under the/usr/local directory. I think this should be a good idea.