Linux - directory structure

Reprint and: Linux system directory structure | rookie tutorial

The file directory structure is a tree structure starting from '/'!

FHS (File System Hierarchy Standard);

1, Four interactive forms of directory

  • Shareable, which can be shared to the directory used by other systems;
  • unshared, device files running on your own machine or socket files related to programs, which are only related to your own machine;
  • variable, frequently changing data;
  • static, the data will not change frequently, such as function library, file description file, host service configuration, etc;

2, Directory structure

/bin

  • binaries, binary files. This directory stores the most commonly used commands;
  • Such as cat, chmod, chown, date, mv, mkdir, cp, bash and other common instructions;
[root@192 ~]# ls /usr/bin |grep -E '^cat$|^chmod$|^mv$|^bash$'
bash
cat
chmod
mv

/boot

  • Store some core files used when starting Linux, including some link files and image files;
  • Common file names are vmlinuz and grub;
[root@192 ~]# ls /boot |grep -E 'grub|vmlinuz'
grub
grub2
vmlinuz-0-rescue-c0dc73705fd44b958694b7f44d6eb95a
vmlinuz-3.10.0-1160.el7.x86_64

/dev

  • device, which stores external devices of Linux;
  • In Linux, the way to access devices and files is the same;
[root@192 ~]# ll /dev/{null,zero,tty,lp*,sd*}
crw-rw----. 1 root lp   6, 0 Feb 27 11:18 /dev/lp0
crw-rw----. 1 root lp   6, 1 Feb 27 11:18 /dev/lp1
crw-rw----. 1 root lp   6, 2 Feb 27 11:18 /dev/lp2
crw-rw----. 1 root lp   6, 3 Feb 27 11:18 /dev/lp3
crw-rw-rw-. 1 root root 1, 3 Feb 27 11:18 /dev/null
brw-rw----. 1 root disk 8, 0 Feb 27 11:18 /dev/sda
brw-rw----. 1 root disk 8, 1 Feb 27 11:18 /dev/sda1
brw-rw----. 1 root disk 8, 2 Feb 27 11:18 /dev/sda2
brw-rw----. 1 root disk 8, 3 Feb 27 11:18 /dev/sda3
crw-rw-rw-. 1 root tty  5, 0 Feb 27 11:18 /dev/tty
crw-rw-rw-. 1 root root 1, 5 Feb 27 11:18 /dev/zero

/etc

  • etcetera, etc. this directory stores all the configuration files required for system management;
  • Such as user's account, password and service start file;
    • /etc/passwd, which stores the basic information of all users;
    • /etc/shadow, which stores the password information of the user;
    • /etc/group, which stores all information of the user group;
    • /etc/gshadow, which stores user group password information;
[root@192 ~]# ll /etc/{passwd,shadow,group,gshadow}
-rw-r--r--. 1 root root 1001 Feb 22 22:33 /etc/group
----------. 1 root root  801 Feb 22 22:33 /etc/gshadow
-rw-r--r--. 1 root root 2337 Feb 22 22:33 /etc/passwd
----------. 1 root root 1181 Feb 22 22:33 /etc/shadow

/home

  • The user's home directory or home directory, which stores the directory generally named after the user's account name;
  • ~, representing the home directory of the current user;
[root@192 ~]# ls /home
test  wz

/lib

  • Library, which stores the most basic dynamic link shared library of the system, similar to the DLL file of Windows;
  • Almost all applications need these shared libraries;
t@192 ~]# ls -d /lib*
/lib  /lib64

/lost+found

  • This directory is generally empty, but some relevant files will be stored after the system is shut down illegally;

/media

  • The Linux system will automatically identify some devices, such as U SB flash disk and optical drive, and then mount them in this directory;

/mnt

  • This directory is where the user temporarily mounts the file system, such as optical drive;

/opt

  • optional, which is the directory where the additional installation software of the host is stored. It is empty by default;

/proc

  • processes, which is a pseudo file system (virtual file system);
  • It stores a series of special files of the current kernel running state, which is the mapping of system memory. You can access this directory directly to obtain system information;
  • The contents of this directory are not on the hard disk but in the memory, and some files can also be modified directly;

/root

  • Home directory of system administrator or super user;

/run

  • This directory is a temporary file system, which stores the information since the system was started;
  • When the system restarts, the files in this directory will be deleted or cleared,

/sbin

  • Superuser binaries, superuser binaries;
  • It stores the system management program used by the system administrator;
  • Such as instructions required for starting up, repairing and restoring the system; The software installed by the machine is placed with / usr/local/sbin;
  • Common instructions, such as fdisk, fsck, ifconfig, init, mkfs;
[root@192 ~]# ll /sbin/{fdisk,fsck,ifconfig,init,mkfs}
-rwxr-xr-x. 1 root root 200496 Oct  1  2020 /sbin/fdisk
-rwxr-xr-x. 1 root root  32888 Oct  1  2020 /sbin/fsck
-rwxr-xr-x. 1 root root  81976 Aug  9  2019 /sbin/ifconfig
lrwxrwxrwx. 1 root root     22 Jan 15 12:37 /sbin/init -> ../lib/systemd/systemd
-rwxr-xr-x. 1 root root  11520 Oct  1  2020 /sbin/mkfs

/srv

  • Service, which stores some data to be extracted after the service is started;
  • Common services such as www, ftp, etc;

/sys

  • Similar to / proc, this directory is also a virtual file system;
[root@192 ~]# ls -1 /sys
block
bus
class
dev
devices
firmware
fs
hypervisor
kernel
module
power

/tmp

  • Temporary, this directory stores some temporary files;
  • It can be accessed by any user and needs to be cleaned regularly;

/usr

  • unix shared resources: shared resources. Many applications and files of users are stored in this directory, similar to program files under Windows;

/Bin - > / usr / bin: instructions used by most users;

/SBIN - > / usr / SBIN: instructions used by super users;

/Lib - > / usr / lib: function library, object file and script;

/usr/include: header file of c/c + +;

/usr/local: store self installed software;

/usr/share: data that stores shared files and can be read regardless of hardware architecture, such as / usr/share/man;

/usr/src: the default location of kernel source code;

[root@192 ~]# ll  /usr
 Total consumption 268
dr-xr-xr-x.   2 root root 49152 Feb 17 23:24 bin
drwxr-xr-x.   2 root root     6 Apr 11  2018 etc
drwxr-xr-x.   2 root root     6 Apr 11  2018 games
drwxr-xr-x.  40 root root  8192 Jan 15 12:39 include
dr-xr-xr-x.  43 root root  4096 Jan 15 12:39 lib
dr-xr-xr-x. 145 root root 81920 Jan 15 12:43 lib64
drwxr-xr-x.  49 root root 12288 Jan 15 12:39 libexec
drwxr-xr-x.  12 root root   131 Jan 15 12:34 local
dr-xr-xr-x.   2 root root 20480 Jan 15 12:40 sbin
drwxr-xr-x. 240 root root  8192 Jan 15 12:40 share
drwxr-xr-x.   4 root root    34 Jan 15 12:34 src
lrwxrwxrwx.   1 root root    10 Jan 15 12:34 tmp -> ../var/tmp

/var

  • Variable, variable. This directory stores things that are constantly expanding;
  • It is customary to put those directories that are often modified under this directory, such as various logs;

/var/cache: some temporary files generated during the operation of the application;

/var/lib: the directory where the data files to be used are stored during the operation of the program itself;

/var/lock: some devices or file resources can only be used by one program at a time. If they are used by two programs, there will be errors, so they need to be locked;

/var/log: store log files, such as / var/log/messages, / var/log/wtmp, etc;

/var/spool: store some queue data, which is usually deleted after being used;

[root@192 ~]# ll  /var
 Total consumption 24
drwxr-xr-x.  2 root root   19 Jan 15 12:39 account
drwxr-xr-x.  2 root root    6 Apr 11  2018 adm
drwxr-xr-x. 13 root root  159 Jan 15 12:45 cache
drwxr-xr-x.  2 root root    6 Oct  2  2020 crash
drwxr-xr-x.  3 root root   34 Jan 15 12:39 db
drwxr-xr-x.  3 root root   18 Jan 15 12:39 empty
drwxr-xr-x.  2 root root    6 Apr 11  2018 games
drwxr-xr-x.  2 root root    6 Apr 11  2018 gopher
drwxr-xr-x.  3 root root   18 Jan 15 12:36 kerberos
drwxr-xr-x. 60 root root 4096 Jan 15 12:45 lib
drwxr-xr-x.  2 root root    6 Apr 11  2018 local
lrwxrwxrwx.  1 root root   11 Jan 15 12:34 lock -> ../run/lock
drwxr-xr-x. 21 root root 4096 Feb 27 11:18 log
lrwxrwxrwx.  1 root root   10 Jan 15 12:34 mail -> spool/mail
drwxr-xr-x.  2 root root    6 Apr 11  2018 nis
drwxr-xr-x.  2 root root    6 Apr 11  2018 opt
drwxr-xr-x.  2 root root    6 Apr 11  2018 preserve
lrwxrwxrwx.  1 root root    6 Jan 15 12:34 run -> ../run
drwxr-xr-x. 12 root root  140 Jan 15 12:39 spool
drwxr-xr-x.  4 root root   28 Jan 15 12:37 target
drwxrwxrwt. 34 root root 8192 Feb 27 18:36 tmp
drwxr-xr-x.  2 root root    6 Apr 11  2018 yp

Keywords: Linux Operating System

Added by sportryd on Sun, 27 Feb 2022 15:17:14 +0200