Directory structure of Linux

Directory structure of Linux

Almost all computer operating systems use a directory structure to organize files. Specifically, it is to store subdirectories and files in a directory, and further store subdirectories and files in a subdirectory, and so on to form a tree file structure. Because its structure is very similar to the branch of a tree, this structure is also called Directory tree.

windows: organize files with one or more roots C:\ D:\

Linux: organize files as a single root/

FHS (standard at directory level)

The full name of FHS (File System Hierarchy Standard), which means directory hierarchy standard in Chinese, is the directory specification standard of Linux.
FHS defines two specifications:

1. What file data should be placed in each directory under the "/" directory.
2. It is defined for the subdirectories of / usr and / var.

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-l5bn1ecg-1622280642341)( -images. jianshu. io%2Fupload_ images%2F16109201-b5a1ae351808c849. png&refer=http%3A%2F%2Fupload-images. jianshu. io&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg? sec=1624869920&t=81b74468539f206a6befd6aaae45ae12)]

This file structure is also used in Linux system. All directories and files are under "root directory", and the directory name is "/". FHS (File System Hierarchy Standard) defines the main directory under the root directory and what files should be stored in each directory.

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly (img-hpcklmdb-1622280642344)( ,10000&q=a80&n=0&g=0n&fmt=jpeg? sec=1624870098&t=46346bc7c3949bd8206e1a44b0daa78d)]

directory structure

/		The root directory of the entire file system, the source of the directory
/bin	deposit Linux Binary files and commands (both ordinary users and super users can execute)
/sbin	deposit Linux Binary files (commands that only super administrators can execute)
/boot	Store the boot file of system startup
/etc	Store all configuration files of the system
/home	Home directory of ordinary users
/root 	root User's home directory
/run	Store relevant documents of running programs in the system
/dev	Storage of equipment documents
/tmp	It is used to store various temporary files. It is a public temporary file storage point
/usr	Store third-party software
/var	Files (system logs, etc.) that store data that needs to be changed during system operation
/lib	Directory where library files are stored (32-bit)
/lib64	Directory where library files are stored (64 bit)
/opt	Store software installed by a third party
/mnt	Directory of temporarily mounted files. such as cdrom,u Disk, etc. cannot be used when directly inserted into the optical drive. It should be mounted before use
/srv	The specific data of the site is provided by the system
/media	Multimedia files
/proc	Virtual file system, in the form of directory, will be the process of pid No. (system information is stored in this directory)
/sys	Directory for storing system related files

Key directory

/dev directory

There are two types of device files: block device file (b) and character device file ©
Device files are generally stored in the / dev directory,

Common equipment documents are described as follows:

/dev stores device files, such as hard disk, hard disk partition, optical drive, etc
/dev/null black hole device, only in and out, similar to spicy chicken recycle bin
/dev/random device for generating random numbers
/dev/zero can generate data far and continuously, which is similar to the ATM. It can withdraw money anytime and anywhere
/dev/pts/0 virtual Bash Shell terminal, available to remote users, 0: one terminal, 1:2 terminals

[root@oldboy /]# ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda3
# sda 		 The first disk in the system
# sda1 	 The first partition in the disk
# sda2 	 The second partition in the disk
# sda3 	 The third partition in the disk

# /dev/null 	 Black holes can absorb anything
[root@oldboy /]# echo 'asrgarg' > /dev/null
[root@oldboy /]# 

# /dev/zero 	 Data can be extracted continuously
# /dev/tty 	 terminal
[root@oldboy /]# tty
# /dev/rundom 	 Random number device
/dev/hd[a-t]            #IDE device
/dev/sd[a-z]            #SCSI device
/dev/fd[0-7]            #Standard floppy drive
/dev/md[0-31]           #Soft raid device
/dev/loop[0-7]          #Local loopback equipment
/dev/ram[0-15]          #Memory
/dev/null               #Infinite data receiving device, equivalent to black hole
/dev/zero               #Infinite zero resources
/dev/tty[0-63]          #Virtual terminal
/dev/ttyS[0-3]          #Serial port
/dev/lp[0-3]            #Parallel port
/dev/console            #Console
/dev/fb[0-31]           #framebuffer
/dev/cdrom              #=> /dev/hdc
/dev/modem              #=> /dev/ttyS[0-9]
/dev/pilot              #=> /dev/ttyS[0-9]
/dev/random             #Random number device
/dev/urandom            #Random number device

/etc directory

/etc is extremely important. All subsequent service configurations are in this directory
/Etc / sysconfig / network script / ifcfg - network card configuration file
/etc/hostname system hostname configuration file
/etc/resolv.conf dns client configuration file
/etc/hosts local domain name resolution configuration file

# /var/log 	 Directory where system logs are stored
[root@oldboy /]# ls /var/log
anaconda            lastlog               vmware-network.4.log
audit               maillog               vmware-network.5.log
boot.log            messages              vmware-network.6.log
/etc/rc /etc/rc.d   ***** #/etc/rc*.d start, or change the scripts or the directory of scripts running at the run level
/etc/hosts          ***** #Local domain name resolution file
/etc/sysconfig/network  ***** #IP, mask, gateway, hostname configuration
/etc/resolv.conf    ***** #DNS server configuration
/etc/fstab          ***** #Start up the automatic mount system, and all partitions will be automatically mounted after starting up
/etc/inittab        ***** #Set what runlevel the Init process will set the system to when the system starts and load the relevant startup file configuration
/etc/exports        ***** #Set the configuration file path for NFS system
/etc/init.d/        ***** #This directory is used to store system startup scripts
/etc/profile        ***** #Global system environment configuration variables
/etc/csh.login,  /etc/csh.cshrc
/etc/issue          ***** #Output information before authentication, default output version kernel information
/etc/motd           #Set the output information after authentication
/etc/mtab           #List of currently installed file systems It is initialized by scripts and automatically updated by mount command Use when you need a list of currently installed file systems, such as the df command
/etc/group          ***** #It is similar to / etc/passwd, but it does not describe users but groups
/etc/passwd         ***** #User database, in which the domain gives the user name, real name, home directory, encrypted password and other information of the user
/etc/shadow         ****** #The shadow password file on the system where the Shadow Password software is installed The shadow password file moves the encrypted password in the / etc/passwd file to / etc/shadow, which is only readable to root This makes it more difficult to decipher the password
/etc/sudoers        ***** #You can the configuration file of sudo command
/etc/syslog.conf    ***** #System log parameter configuration
/etc/login.defs     #File for setting user account restrictions
/etc/securetty      #Confirm the secure terminal, that is, which terminal allows root login It is not possible to break into the network through the general console (or super modem) and get privileges only
/etc/printca        #Similar to / etc/termcap, but for printers Grammar is different
/etc/shells         #List trusted shells The Chsh command allows the user to change the login shell within the scope specified in this file The service process ftpd that provides a machine FTP service checks whether the user shell is listed in the / etc/shells file. If not, the user will not be allowed to log in
/etc/xinetd.d       #If the server runs in xinetd mode, its scripts should be placed in this directory. Some systems do not have this directory, such as Slackware, and some old versions do not. It exists in the newer version of Redhat Fedora.
/etc/opt/           #/Configuration file for opt /
/etc/X11/           #X_ Configuration file of window system (version 11)
/etc/sgml/          #Configuration file for SGML
/etc/xml/           #XML configuration file
/etc/skel/          ***** #By default, when creating a user, copy the directory to the home directory

/proc directory

The virtual file system archives the kernel and process status as text files (the system information is stored in this directory).

For example: uptime, network. In Linux, mount in the corresponding Procfs format. The files in this directory can only be viewed and cannot be changed (including root)

/proc/meminfo           ***** #View memory information
/proc/loadavg           ***** #Remember top and uptime? you 're right! The top three averages are recorded here!
/proc/uptime            ***** #This is the information that will appear when using uptime!
/proc/cpuinfo           ***** #Information about the processor, such as type, manufacturer, model and performance.
/proc/cmdline           #Relevant parameters issued when loading the kernel! Refer to this file to understand how the system starts!
/proc/filesystems       #At present, the system has loaded the file system Luo!
/proc/interrupts        #Current IRQ allocation status on the system.
/proc/ioports           #The I/O address configured by each device on the current system.
/proc/kcore             #This is the size of memory! It's big, isn't it! But don't read him!
/proc/modules           #At present, the list of modules loaded by our Linux can also be thought of as drivers!
/proc/mounts            #The data that the system has mounted is the data called by the mount command!
/proc/swaps             #Where is the memory loaded by the system? ha-ha! The used partition is recorded here!
/proc/partitions        #Using fdisk -l will result in all current partition s, right? There are also records in this document!
/proc/pci               #On the PCI bus, the details of each device! Available lspci to check!
/proc/version           #The core version is the content displayed with uname -a!
/proc/bus/*             #Some busbar devices and U SB flash disk devices are also recorded here!

/usr directory

The default software will be stored in this directory. A second level for storing read-only user data; Contains the vast majority of user tools and applications.

/usr/X11R6          #Directory where X-Windows is stored;
/usr/games          #Store the games of XteamLinux;
/usr/doc            #Linux technical documents;
/usr/include        #It is used to store the header files required for developing and compiling applications under Linux;
/usr/lib            #Store some commonly used dynamic link shared libraries and static archives;
/usr/man            #The directory where the help document is located;
/usr/src            #Linux open source code exists in this directory. Enthusiasts, don't let go;
/usr/bin/           #Unnecessary executable files (not required in single user mode); For all users.
/usr/lib/           #/Libraries of binaries in / usr/bin / and / usr/sbin /.
/usr/sbin/          #Non essential system binaries, such as daemons for a large number of network services.
/usr/share/         #Architecture independent (shared) data.
/usr/src/           #Source code, such as kernel source code and its header file.
/usr/X11R6/         #X Window system version 11, Release 6
/usr/local/         #The third level of local data, specific to this host. Generally speaking, there are further subdirectories, such as bin /, lib /, share / This is the / usr directory provided to general users, where general application software is installed;

Soft link directory

/bin --> /usr/bin
/sbin --> /usr/sbin
/lib --> /usr/lib
/lib64 --> /usr/lib64

File location

  • Relative path: paths that do not start from / are relative paths (~ excluded)
  • Absolute path: the path from / is the absolute path

Two special directories

.current directoryRelative path
...Parent directoryRelative path

cd switch directory

# Enter the network scripts of the current directory 
[root@oldboy /etc/sysconfig]# cd ./network-scripts/
[root@oldboy /etc/sysconfig/network-scripts]# 

# Enter / etc / sysconfig / network scripts in the upper directory
[root@oldboy /]# cd ../etc/sysconfig/network-scripts/
[root@oldboy /etc/sysconfig/network-scripts]# 

# Enter the current user's home directory
[root@oldboy /etc/sysconfig/network-scripts]# cd ~
[root@oldboy ~]#

#Return to the last directory
[root@oldboy ~]# cd -
[root@oldboy /etc/sysconfig/network-scripts]# 

# Enter the current user's home directory
[root@oldboy /etc/sysconfig/network-scripts]# cd
[root@oldboy ~]# 

Keywords: Linux

Added by Dave2222 on Tue, 08 Feb 2022 07:29:17 +0200