Detailed explanation of the role of each directory in the Linux (centos) system

from : http://www.jb51.net/LINUXjishu/32180.html




Types of file systems

LINUX has four basic file system types: ordinary files, directory files, connection files and special files, which can be identified by the file command.

Ordinary files: such as text files, C language metacodes, SHELL scripts, binary executable files, etc., you can use cat, less, more, vi, emacs to view the content, and use mv to rename.

Directory file: including file name, subdirectory name and its pointer. It is the only place LINUX stores filenames, and ls can be used to list directory files.

Link files: are those directory entries that point to the same inode. Use ls to view yes, the sign of the connection file starts with l, and the file is followed by "->" to point to the connected file.

Special files: Some LINUX devices such as disks, terminals, printers, etc. are represented in the file system, so a type of file is a special file, which is often placed in the /dev directory. For example, floppy drive A is called /dev/fd0. LINUX has no concept of C:, but uses /dev/had from the first hard disk.


   One of the most confusing questions for linux newbies is where do the files exist? Especially for those who are new to Windows, the directory structure of linux looks a bit strange. So, let's talk about the main directories under linux and what they are used for.

    /

    This is the root directory. The mothership. The home field. The one and only top directory for your whole computer. Everything, and I mean EVERYTHING starts here. When you type '/home' what you're really saying is “start at / and then go to the home directory."

    /

    This is the root directory. There is one and only one root directory for your computer. Everything, I mean everything starts here. For example: when you type "/home" in the terminal, you are actually telling the computer to start with / (the root directory) and then go to the home directory.

    /root

    This is where the root user lives. The root user is the god of your system. Root can do anything, up to and including removing your entire filesystem. So be careful using root.

    /root

    This is the system administrator (root user )Directory. For the system, the system administrator is like a god, it can do anything to the system, even delete your files. Therefore, use the root account with care.

    /bin

    Here's where your standard linux utilities(read programs) live — things like “ls” and “vi” and “more”. Generally this directory is included in your path. What this means is that if you type 'ls', /bin is one of the places your shell will look to see if 'ls' means anything.

    /bin

    is where standard (or default) linux tools are stored, such as "ls", "vi" and "more" etc. Typically, this directory is already included in your "path" system variable. What does it mean? That is: when you enter ls in the terminal, the system will go to the /bin directory to find out whether there is an ls program.

    /etc

    Here's where the administrative and system configuration stuff lives. For instance, if you have samba installed, and you want to modify the samba configuration files, you'd find them in /etc/samba.

    /etc

    here mainly stores system configuration aspects of the document. For example: you installed the samba package, when you want to modify the samba configuration files, you will find them (configuration files) in the /etc/samba directory.

    /dev

    Here's where files that control peripherals live. Talking to a printer? Your computer is doing it from here. Same goes for disk drives, usb devices, and other such stuff.

    /dev

    mainly stores files related to devices (including peripherals) (Unix and Linux systems both treat devices as files). Want to connect a printer? The system starts working from this directory. In addition, some disk drives, USB drives, etc. are placed in this directory.

    /home

    Here's where your data is stored. Config files specific to users, your Desktop folder(whick makes your desktop what it is), and any data related to your user. Each user will have their own /home/username folder, with the exception of the root user.

    /home

    mainly stores your personal data here. The specific settings files of each user, the user's desktop folder, and the user's data are all placed here. Each user has its own user directory, located at: /home/username. Except for the root user, of course.

    /tmp

    This is the Temporary folder. Think of it as a scratch directory for your Linux system. Files that won't be needed by programs once their used once or twice are put here. Many Linux systems are set to automatically wipe the /tmp folder at certain intervals, so don't put things you want to keep here.

    /tmp

    is the temporary directory. For some programs, some files are used once or twice, and they are not used again, and files like this are placed here. Some linux systems will automatically clean up this directory on a regular basis, so do not put important data here.

    /usr

    Here's where you'll find extra utilities that don't fit under /bin or /etc. Things like games, printer utilities, and whatnot. /usr is divided into sections like /usr/bin for programs, /usr/share for shared data like sound files or icons, /usr/lib for libraries whick cannot be directly run but are essential for running other programs. Your package manager takes care of the things in /usr for you.     Under

    /usr you can find

Extra tools that don't fit in the /bin or /etc directories. For example, like games, some printing tools and so on. The /usr directory contains many subdirectories: /usr/bin directory is used to store programs; /usr/share is used to store some shared data, such as music files or icons, etc.; /usr/lib directory is used to store files that cannot be directly run, but are some function library files necessary for many programs to run. Your package manager (probably "Synaptic") will automatically manage the /usr directory for you.

    /opt

    Here's where optional stuff is put. Trying out the latest Firefox beta? Install it to /opt where you can delete it without affecting other settings. Programs in here usually live inside a single folder whick contains all of their data, libraries, etc.

    / opt

    here mainly stores those optional programs. Do you want to try the latest beta version of firefox? Then install it in the /opt directory, so that when you finish trying and want to delete firefox, you can delete it directly without affecting any other settings of the system. For programs installed in the /opt directory, all its data, library files, etc. are placed in the same directory.

    For example, the beta version of firefox you just installed can be installed in the /opt/firefox_beta directory. The /opt/firefox_beta directory contains all the files, libraries, data, etc. needed to run firefox. To delete firefox, you just need to delete the /opt/firefox_beta directory, very simple.

    /usr/local

    This is where most manually installed(ie. outside of your package manager) software goes. It has the same structure as /usr. It is a good idea to leave /usr to your package manager and put any custom scripts and things into /usr /local, since nothing important normally lives in /usr/local.

    /usr/local

    mainly stores those manually installed software, that is, software not installed by "Synaptic" or apt-get. It has a similar directory structure to the /usr directory. Let the package manager manage the /usr directory and put custom scripts (scripts) under the /usr/local directory, I think it should be a good idea.

    /media Some     distros

    use this folder to mount things like usb disks, cd or dvd drives and other filesystems.

    /media

drives, etc.

Replenish:

       /bin The commands required by the system are located in this directory, such as ls, cp, mkdir and other commands; the functions are similar to /usr/bin, and the files in this directory are all executable commands that ordinary users can use. The most basic commands required as a base system are placed here (/usr/bin and /usr/sbin are similar to the directories corresponding to the "/" root directory (/bin and /sbin), but are not used for basic startup ( For example, in emergency maintenance). Most commands are in this directory. ).

        /boot The Linux kernel and the file directory required to boot the system program, such as the vmlinuz initrd.img file, are located in this directory. In general, the GRUB or LILO system boot manager is also located in this directory.

/lost+found In the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. The fsck tool will check here when the system is booting and repair the corrupted filesystem. Sometimes there is a problem with the system, and many files are moved to this directory, which may be repaired manually, or moved to the original location.

/mnt This directory is generally used to store the mount directory of the mounted storage device, such as cdrom and other directories. See the definition of /etc/fstab. Sometimes we can let the system start to automatically mount the file system, and it is also possible to put the mount point here. It mainly depends on how it is defined in /etc/fstab; for example, the CD-ROM can be mounted to /mnt/cdrom.

/opt means optional, some packages will also be installed here, that is, custom packages. For example, in Fedora Core 5.0, OpenOffice is installed here. Some software packages compiled by ourselves can be installed in this directory; software installed through source packages can be installed through the ./configure --prefix=/opt/ directory.

/proc When the operating system is running, process information and kernel information (such as cpu, hard disk partition, memory information, etc.) are stored here. The mount directory of the file system proc disguised by the /proc directory, proc is not a real file system, and its definition can be found in /etc/fstab.

/sbin is mostly the storage of commands related to system management. It is the place where the executable commands of the super-privileged user root are stored. Ordinary users do not have permission to execute commands in this directory. This directory is related to /usr/sbin; /usr/X11R6/sbin or The /usr/local/sbin directory is similar; we just need to remember that everything contained in the directory sbin can only be executed with root privileges.

/usr This is the directory where the system stores programs, such as commands, help files, etc. There are many files and directories in this directory. When we install a package that is officially provided by a Linux distribution, it is mostly installed here. If there is a server configuration file involved, the configuration file will be installed in the /etc directory. The /usr directory includes the font directory /usr/share/fonts, the help directory /usr/share/man or /usr/share/doc, the common user executable directory /usr/bin or /usr/local/bin or / usr/X11R6/bin, the executable command storage directory of the super-authorized user root, such as /usr/sbin or /usr/X11R6/sbin or /usr/local/sbin, etc.; and the program header file storage directory /usr/include .

The content of the /var directory changes frequently. You can tell by the name. We can understand it as the abbreviation of vary. There is /var/log under /var, which is the directory used to store system logs. The /var/www directory is the storage directory that defines the Apache server site; /var/lib is used to store some library files, such as MySQL, and the storage place of the MySQL database;

a little trick about the /opt directory

In Linux, the /opt directory is a directory for storing some large software or some special software. For example, Google Chrome (Google Chrome) is installed in /opt by default. However, we generally do not separate opt into a separate area, because most of the time /opt is empty, even if the software is installed, it will not be too much, and the capacity of some software is relatively large, which will occupy the capacity of / , we can create a directory in other places you want to "transfer" /opt to other places. For example, my /usr is divided into a separate area with a capacity of 50G. Don't waste such a large space, right? And /usr is the place where software is installed, so I can create a folder called opt under /usr, then right-click the opt under /usr, select "Create Link", and get a link called "opt-to-opt" file, then cut this file to /, delete the original /opt, and then rename the "link to opt" to opt. Later, the software we installed in /opt is actually installed in /usr/ opt (actually a symbolic link).

/usr/local This directory is generally used to store the storage directory of the user's self-compiled and installed software; generally, the software installed through the source package, if the installation directory is not specified, it is generally installed in this directory. There are subdirectories under this directory. See for yourself.

/usr/share System shared things are stored, such as /usr/share/fonts is the font directory, /usr/share/doc and /usr/share/man help files.

/var/log system log storage, analysis log depends on the contents of this directory;

/var/spool printer, mail, proxy server and other spool directories;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326401159&siteId=291194637