Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Linux system directory structure


May 22, 2021 Linux


Table of contents


Linux system directory structure

After you log on to the system, enter the command under the current command window:

 ls / 

You'll see the following image:

Linux system directory structure

Tree directory structure:

Linux system directory structure

Here's how these directories are interpreted:

  • /bin
    Bin is an abbreviation for Binary, a directory that holds the most frequently used commands.

  • /boot:
    Here are some of the core files used to start Linux, including some connection files and mirror files.

  • /dev:
    dev is an abbreviation for Device (device), which holds linux's external devices in the same way that devices are accessed and files are accessed.

  • /etc:
    This directory is used to hold all the configuration files and subdirecttors required for system management.

  • /home
    The user's home directory, in Linux, each user has its own directory, which is usually named after the user's account.

  • /lib
    This directory holds the system's most basic dynamic connection shared library, which acts like a DLL file in Windows. Almost all applications need to use these shared libraries.

  • /lost+found
    This directory is generally empty, and when the system shuts down illegally, some files are stored here.

  • The /media linux system automatically recognizes devices such as USB drives, optical drives, and so on, and when identified, linux mounts the identified devices to this directory.

  • /mnt
    The system provides the directory in order for the user to temporarily mount another file system, we can mount the optical drive on /mnt/, and then enter the directory to view the contents of the optical drive.

  • /opt
    This is the directory placed for the host to install additional software. F or example, if you install an ORACLE database, you can put it in this directory. The default is empty.

  • /proc
    This directory is a virtual directory, it is a mapping of system memory, we can directly access this directory to obtain system information.
    The contents of this directory are not on the hard disk but in memory, and we can also directly modify some of the files inside, such as the following command to block the host's ping command, so that others can not ping your machine:

    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
  • /root
    The directory is the user home directory of the system administrator, also known as the super-privileged person.

  • /sbin
    s is what Super User means, and it's a system manager used by the system administrator.

  • /selinux
    This directory is unique to Redhat/CentOS, and Selinux is a security mechanism, similar to windows firewalls, but it's a complex one, and this directory holds selinux-related files.

  • /srv
    The directory holds some of the data that needs to be extracted after the service is started.

  • /sys
    This is a big change to the linux 2.6 kernel. An emerging file system sysfs in the 2.6 kernel is installed in this directory.

    The sysfs file system integrates information from the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo-terminals.

    The file system is an intuitive reflection of the kernel device tree.

    When a kernel object is created, the corresponding files and directories are also created in the kernel object subsys system.

  • /tmp
    This directory is used to hold some temporary files.

  • /usr
    This is a very important directory, and many of the user's applications and files are placed in this directory, similar to the project files directory under windows.

  • /usr/bin:
    The application used by the system user.

  • /usr/sbin:
    The more advanced management programs and system daemons used by super users.

  • /usr/src: The default drop directory for kernel source code.

  • /var
    This directory contains things that are constantly expanding, and we are used to putting those that are often modified under this directory. Includes various log files.

In linux systems, there are several directories that are more important, usually need to be careful not to delete or change internal files at will.

/etc: Also mentioned above, this is a profile in the system, and if you change a file in that directory, the system may not start.

/bin, /sbin, /usr/bin, /usr/sbin: This is the placement directory of the system's preset execution files, such as ls is in the /bin/ls directory.

It is worth noting that /bin, /usr/bin are instructions for system users (ordinary users other than root), while /sbin, /usr/sbin is instructions for root.

/var: This is a very important directory, the system runs a lot of programs, then each program will have the corresponding logs generated, and these logs are recorded in this directory, specifically in the /var/log directory, in addition to the preset placement of mail is also here.