Linux common important directory and the role of each directory

Source: Internet
Author: User

The following are some of the most important directories and the various functions of Linux systems:
/
root directory.
Contains almost all of the file directories. Equivalent to a central system. The simplest way to enter is: CD/.

/boot
Directories such as boot programs, kernels, and so on.
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
The host directory of commands that the superuser can use.
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. The following will be specifically differentiated.

/bin
The directory in which commands can be used by ordinary users.
The commands required by the system are located in this directory, such as LS, CP, mkdir, etc., 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.

/lib
The shared library directory of the program under the root directory.
This directory contains the shared libraries that are required for system booting and when the root user executes the command. Do a less than good but more figurative analogy, dot similar to the system32 directory above Windows. 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.

/dev
Device Files 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
Home directory for normal users ($HOME directory.
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. In general, each user of the system has their own home directory, and the directory is stored under//under the name of the username (for example, the Quietheart user, whose home directory is named/home/quietheart. The directory holds the vast majority of user files (user's own profile, custom files, documents, data, etc.), except for the root user (see the/root directory below). 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.

/etc
The global configuration file holds the 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.
This directory is also a very important directory for the system, which is similar to the "program Files" directory above windows (please forgive me that I might be less appropriate to do this ^_^.) 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 storage locations for executables that are not normally called directly.
This directory is similar to the/lib directory, the rationale is that the files stored here should be the/bin directory for the application of the library files required to store, and do not rule out some exceptions.

/usr/bin
A directory that is used by the general consumer and is not a required executable file such as System self-test.
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 executable file that the administrator uses for non-system must be stored in 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 C program language compiles the header files used.
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
Installs a generic default path for 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 directory uses a special file system format (proc format, the kernel supports this format. It contains all the virtual files. They are not saved on disk or Occupy disk space (although command ls-c will show their size). When you look at them, you actually see the information in memory that helps us understand the information inside the system. For example:
├1/the directory of information about process 1. Each process is/proc under a directory named its process number.
├cpuinfo processor information, such as type, manufacturer, model, and performance.
├devices a list of device drivers for the currently running core configuration.
├DMA Displays the DMA channel currently in use.
├filesystems the file system of the core configuration.
├interrupts shows the interrupts used, and how many of each there has been.
├ioports the I/O port currently in use.
├kcore System physical memory image. The same size as physical memory, but does not actually account for so much memory;
├kmsg the core output message. is also sent to the syslog.
├ksyms core symbol table.
├loadavg system "average load"; 3 meaningless indicators indicate the current workload of the system.
├meminfo memory usage information, including physical memory and swap.
├modules which core modules are currently loaded.
├net Network protocol status information.
├self to view the symbolic connection of the process directory of the/PROC program.
Different states of the ├stat system
├uptime the length of time the system started.
└version Core version.

/opt
Optional file directory.
This directory represents the optional meaning, some custom software packages or the first-party tools that can be installed here. For example, in Fedora Core 5.0, OpenOffice is installed here. Some of our own compiled packages can be installed in this directory, through the source package installed software, you can set their installation path to/opt to install. This directory works a bit like/usr/local.

/mnt
Temporary mount directory.
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. In general, we'd better set up a few subdirectories under the/mnt directory and mount them on top of these subdirectories, because normally we might not just mount a device?

/media
Mount the media device directory.
Mounted media device catalogs, typically external devices are mounted here, such as CDROM. For example, we insert a USB flash drive, we will generally find that Linux automatically set up a disk directory in this directory, and then mount the USB stick to the disk directory, by accessing the disk to access the USB drive.

/var
A directory in which 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
The location where the files are recovered.
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.

In addition, some directory beginners easy to confuse, here is 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 (binaries) for system administration, which are generally not used by ordinary users and 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 common important directory and the role of each directory

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.