Linux File system directory structure Resolution

Source: Internet
Author: User

Linux system directory structure

/root directory:

Contains almost all of the file directories. The simplest way to enter is: CD/. Note the difference from the root user. Root user refers to system administrator root and Superuser.

Directory for boot/boot, kernel, etc.:

This directory, including the necessary files in the boot process, the boot program related files (such as Grub,lilo and the corresponding configuration file and Linux operating system kernel-related files (such as vmlinuz, etc. are generally stored here. At the beginning of the boot phase, the kernel is loaded into memory by the bootloader, and the kernel is started (this time, the virtual file system does not exist, although the loaded kernel is read from the hard disk, but does not go through the Linux virtual file system, this is the lower level of things to achieve. The kernel then creates the virtual file system itself, and from other subdirectories of the virtual file system (for example,/sbin and/etc loads other programs or services or specific actions that need to be started on boot (some can be configured by the user to modify the appropriate files in the appropriate directory). If our machine contains multiple operating systems, you can modify a configuration file in this directory (for example, grub.conf to adjust the startup default operating system, the system-initiated menu, and the startup delay parameters.

/sbin Storage directory for system administration commands:

Storing most of the commands that involve system administration (for example, the INIT program that directs the system) is the executable command repository for Superuser root, and the normal user does not have permission to execute commands in this directory (but it may also be used by ordinary users.) This directory and/usr/sbin; Directories such as/usr/x11r6/sbin or/usr/local/sbin are similar, and we want to keep in mind that everything contained in the directory sbin is rooted to execute, and that's OK.

/bin directory of commands that ordinary users can use:

Unlike the/sbin directory, the command root user and the normal user are available in this directory. such as LS, CP, mkdir and other commands; Similar directories are/usr/bin,/usr/local/bin and so on. The files in this directory are executable and can be used by ordinary users. The most basic command required as a basic system is to put it here. Compared to the/usr/bin directory, this directory is the most important for the system, because these commands can be executed even if only the partitions that are included are mounted. This directory contains programs that may be dependent on the startup program.

Note: in centos7 , the bin directory under the root directory is just a Soft connection to/usr/bin.

Shared libraries for/lib programs:

This directory contains the kernel modules and shared libraries that are required for system startup and for running commands on the root file system. Similar to dynamic-link library (DLL) files in Windows systems. Manager said that the files stored here should be the/bin directory for the application of the library files required to store, and do not exclude some exceptions. Similar directories are/usr/lib,/usr/local/lib and so on.

Note: in centos7 , Lib and lib64 are connected to /usr/lib and /usr/lib64 file, the contents of these two files are different .

/dev Device file directory:

In Linux, devices are in the form of files, where the device can be hard disk, keyboard, mouse, network cards, terminals, and other devices, access to these files can be accessed to the appropriate device. The device files can be created using the Mknod command, but in order to convert access to these device files into devices, a device driver module is provided to the device (typically after the device driver is compiled, the resulting result is a *.ko type of binary file, after the kernel boots , we can access the device through the device file after loading the corresponding device driver via Insmod and other commands. In general, if you want a Linux system to support a device, just one thing: the appropriate hardware device, the driver module that supports the hardware, and the corresponding device files.

Home directory ($HOME directory) for a normal User:

On Linux machines, the user home directory is usually placed directly or indirectly in this directory. The structure is usually determined by the administrator of the local machine. Typically, each user of the system has its own home directory, and the directory is stored under//under the name of the user name (for example, User1 user, whose home directory is named/home/user1. The directory holds the vast majority of users ' files (user's own profile, custom files, documents, data, etc.), except for the root user (see the/root directory later in this document). Because this directory contains the user's actual data, the system administrator usually mounts a separate partition for the directory, so that the file system format of the directory may be different from the other directories (although the directory is still a subtrees tree in the root directory), which facilitates data maintenance.

/root $home directory for user root:

The master directory of the system administrator (that is, root or Superuser) is special and is not stored in/home, but is placed directly in the/root directory, because if the system only mounts/directories, if the root home directory is placed at//, it will cause the root user to have no access to their home directory.

/etc configuration file directory:

Systems and programs can be configured by modifying the appropriate configuration file. For example, to configure the system to boot up those programs, configure a program to show when the start of the style and so on. Usually these profiles are stored in the/etc directory, so if you want to configure something, you can look under/etc to find the files we may need to modify. Some large packages, such as X11, are their own subdirectories under/etc. The system configuration file can be placed here or in/usr/etc. However, the program always looks for the desired configuration files in the/etc directory, and you can also link these files to the directory/usr/etc. Another common phenomenon that needs to be noted is that when a program runs under a user, a profile may be generated in the user's home directory (typically the file is initially a copy of the corresponding configuration file in/etc, storing the configuration corresponding to the "Current user"). This allows the current user to change the behavior of the program by configuring the configuration file for the home directory, and this behavior is only specific to that user. The reason is: In general, a program start, if you need to read some configuration files, it will first read the current user home directory configuration file, if it exists, if it does not exist in/etc to read the global configuration file and then start the program. Is that this configuration file is not automatically generated, we manually create a file in their home directory, There are also many programs that first read the file to this home directory and use its configuration as the startup option (for example, we can create a vim program in the home directory. VIMRC, to configure its own vim program.

/usr This directory contains the command library files and files that are not modified in the usual operation, and is one of the most important directories of the system:

This directory is also a very important directory for the system, which is similar to the "program Files" directory above Windows. In the previous/USR directory equivalent to the current/home directory, so now one of the names of the/usr directory is: User System Resource. When installing the program, the default is to install a subfolder within this file. After entering the command, the system executes the program under/usr/bin by default (assuming that the path to the directory has been added to the environment variables of the system. This directory usually also mounts a separate disk partition, which should save the shared read-only class file so that it can be mounted by different hosts running Linux.

/usr/lib the target library file, including the dynamic Connection library, plus some places where executables are not normally called directly:

This directory is similar to the/lib directory, where the files should be stored in the/bin directory for the application of the library files, and do not rule out some exceptions.

/usr/bin the directory of the necessary executables for general users and not for system self-test, etc.:

This directory is equivalent to the directory under the root file system (/bin, non-boot system, non-repair system, and non-locally installed programs are generally placed in this directory.

/usr/sbin the non-system mandatory executable file that the administrator uses to store the directory:

This directory is equivalent to the directory under the root file system (/sbin, a binary file that holds the hypervisor, and these files are not required for system boot or file system mount/USR directories or repair systems.

/usr/share the directory where the shared files are stored:

Different subdirectories in this directory hold shared data for specific applications (such as program documentation information) for the same operating system while working under different architectures. Users can find these similar data typically placed in the/usr/doc or/usr/lib or/usr/man directories.

/usr/include the header file used by the program compilation:

The header files needed to develop and compile applications under Linux are typically stored here, using some library functions through the header file. By default, this path is added to the environment variable, so the compiler will automatically search for the path when compiling the program, and find the header files that may be included in your program.

/usr/local General default path for installing local programs:

When we download a program source code, compile and install, if not specifically specify the program path installed, then the default will be the program-related files installed in the directory of the corresponding directory. For example, the installation of the program executable file is installed (the essence of the installation is copied to the/usr/local/bin, this program (the executable file needs to rely on the library files are installed in the/usr/local/lib directory, the installed software if it is a development library (such as QT, GTK and so on the corresponding header file may be installed in the/usr/local/include and so on. In other words, the contents of this directory is usually the default path of the software we install later, if the default path is chosen as the installation path of the software, the files of the installed software are restricted to this directory, the subdirectories of which are the corresponding subdirectories of the root directory.

/proc Special Files directory:

This is a special directory and it is also a virtual file system. Each file in this directory allows you to view the kernel information of the system.

/OPT Reserved Files directory:

Some custom packages or third-party tools can be installed here.

/mnt a universal mount point for a file system or device:

This directory is generally used to store mounted storage device mount directory, such as disk, optical drive, network file system, etc., when we need to mount a disk device, we can mount the disk device to this directory, so that we can directly access the directory to access the disk. You can create several subdirectories under the/mnt directory, mount them on top of these subdirectories, or set them in any location, but this is not recommended.

/media Mounted Media Device directory:

Mounted media device catalogs, typically removable devices are mounted here, such as Cdrom,loppy and Cdrecord.

The directory where/var content changes frequently:

The size of the files in this directory may change, such as buffer files, log files, cache files, etc. are generally stored here.

/tmp temp file directory:

This directory holds some temporary files in the system, and the files may be automatically emptied by the system. System directly to the TMPFS type of file system mount to this directory, TMPFS file system is supported by the Linux kernel, the data in this file system is actually in memory, because the memory data loss is volatile, when the system restarts we will find that the directory was emptied.

/lost+found where the recovered files are stored:

When the system crashes, the files that need to be recovered during the system repair process may be found here, and this directory is generally empty.

The above catalogue is the most common and important directory. Some of these catalogs are easy to confuse, so here's a simple distinction:

/bin,/sbin and/usr/bin,/usr/sbin:

/bin generally stores the "must" program (binaries) for users and systems.

/sbin generally holds "required" Programs for system administration (binary files, which are generally not used by ordinary users, and are used by root users).

/usr/bin generally stores only "not required" programs (binaries) for users and systems.

/usr/sbin General storage is not a required program (binary file) for system administration for system administration.

/lib and/usr/lib:

The difference between/lib and/usr/lib is similar to/bin,/sbin and/usr/bin,/usr/sbin.

/lib generally stores the "must" libraries (binaries) for users and systems.

/usr/lib generally stores only "not required" libraries (binaries) for users and systems.

Linux File system directory structure Resolution

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: 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.