


In-depth analysis of Linux directory structure: root directory, user directory, system configuration, etc.
1. Linux directory structure
2. Directory purpose
/Root directory
/rootroot administrator home directory
/boot stores Linux startup files
/etcStorage system and software configuration files
/usr User command program storage directory
/homeGeneral home owner directory
/mnt device/file system mount point
/bin stores the most commonly used operating commands
/optApplication software installation directory, such as database, etc.
/tmp temporary directorylinux searches the directory where the file is located, stores temporary files
/var variable information storage area (system logs, website files, etc.)
/proc virtual file systemThe directory where the Linux search file is located, including process information
/sbin system administrator command storage directory
/dev device file, (hard disk is more common)
/libThe most basic dynamic link shared library
Common files in/etc directory
/etc/sshSSH remote shell configuration directory
/etc/shadow, /etc/passwd user configuration file, user password configuration file
/etc/NetworkManager/Network configuration directory of the NetworkManager program of Unongxin UOS
/etc/group user group configuration file
/etc/servicesService and port information
Common files in/proc directory
/proc/cpuinfo file to view detailed information about the cpu
All file systems currently mounted in the /proc/mounts system
/proc/version The kernel version number currently running on the system
/proc/vmstat Statistics of the current system virtual memory.
Common files in/dev directory
/dev/sda represents the first hard drive
/dev/sda1 represents the first partition of the first hard disk
/dev/sda2 represents the second partition of the first hard disk
/dev/sdb represents the first hard drive
/dev/cdrom represents the hard disk
/dev/zero is used for null character output
/dev/null is used to be input, similar to the trash can
3. Directory path
Pathname
Absolute path: Start with the root directory.
Relative path: Start with the current directory.
Current directory..Superior directory.
[Note] When accessing a file, the user must provide the path where the file is located.
Paths are divided into relative paths and absolute paths.
The absolute path refers to the path starting from the "root" linux system tutorial, also known as the full path;
The relative path is the path starting from the user's working directory.
It should be noted that there is only one absolute path and one relative path to a certain file in the tree directory structure. The absolute path is deterministic and unchanged, while the relative path changes continuously as the user's working directory changes. When users want to access a file, they can refer to it by path name. And you can reference the file to be accessed based on its relative position to the user's working directory, without enumerating the full path name of the file.
Absolute path, relative path
➢Absolute path
Full path starting with /
[admin@linux]$cd/u01/app/oracle
[oracle@OEL64oracle]$pwd
/u01/app/oracle
➢Relative path
Does not start with /, only relative to the current working directory
[oracle@OEL64oracle]$cd/u01/app
[oracle@OEL64app]$cd./oracle
[oracle@OEL64oracle]$pwd
/u01/app/oracle
..Indicates the upper-level directory of the current directory, that is, the parent directory
[root@OEL64tmp]#cd/u01/app/oracle
[root@OEL64oracle]#pwd
/u01/app/oracle
[root@OEL64oracle]#cd..
[root@OEL64app]#pwd
/u01/app
.Indicates the current directory
[root@OEL64app]#pwd
/u01/app
[root@OEL64app]#cd./oracle
[root@OEL64oracle]#pwd
/u01/app/oracle
4. File name
File case resolution
Files starting with "." are implicit files
File name can be up to 255 characters (all characters are valid except forward slashes)
[oracle@OEL64~]$ls-al
total152
drwx------.26oracleoinstall4096Sep1915:59.
drwxr-xr-x.6rootroot4096Jun272013..
-rw-r--r--.1oracleoinstall685Sep1817:35.bash_profile
5. Basic directory file type-flag
File type representative characters:
Normal file-
Directory file d
Linked file l
Block device file b
Character device c
6. Directory file type-color
File type color:
Normal file--------------------Black
Directory file--------------------Black
Symbolic link file--------------black
Device File--------------------Black
Executable file-----------------green-red
Picture file--------------------Pink green
Compressed file---------------------black
7. Common commands
Basic command: lspwd
Directory operation command: cdmkdirrmdirrmcpmv
File operation command: lessmorelessnanocattouchfile
Basic command: ls
ls command is used to display the target list, which is a highly used command in Linux.
The output information of the ls command can be displayed with color highlighting to partition different types of files.
Sentence pattern
ls(options)(parameters)
usage:
ls only lists visible files in the current directory
ls-l lists detailed information about files visible in the current directory
ls-hl lists detailed information and displays file size in readable size
ls-al lists detailed information of all files (including hidden)
Basic commands: pwd, cd
pwd displays the current path
$cd/u01/app/oracle
$pwd
/u01/app/oracle
cd changes the current working directory
$pwd
/u01/app/oracle
$cd/etc
$pwd
/etc
Create and delete directory commands: mkdirrmdir
mkdir creates new directory
rmdir delete empty directory
Delete command: rm
rm delete files and directories
Note: Be careful when using the rm command. Because once a file is deleted, it is difficult to recover it.
For example: rm-rf/
Sentence pattern
rm(option)(parameter)
Options
-d: Delete the directory;
-f: Forcefully delete files or directories;
-i: Ask the user before deleting existing files or directories;
-r or -R: Recursive processing, processing all files and subdirectories in the specified directory together;
-v: Display the detailed execution process of the command.
Common usage:
rm-rf does not ask, delete all files under directory a
Copy command: cp
The cp command is used to copy one or more source files or directories to the specified destination file or directory.
Sentence pattern
cp(option)(parameter)
Options
-f: Forcefully copy files or directories, regardless of whether the target file or directory already exists;
-i: Ask the user before overwriting existing files
-R/r: Recursive processing, processing all files and subdirectories in the specified directory together;
-v: Display the operations performed by the command in detail.
Common usage:
cp-rf/a/b
or
cp-r-f/a/b
Commands: mv, touch, file
mv Unicom or rename file
#mv/tmp/b.txt/home/oracle/.
#cd/home/oracle
#ls-alb.txt
-rw-r--r--.1rootroot0Sep2216:30b.txt
touch creates an empty file
#cd/tmp
#touchc.txt
#ls-alc.txt
-rw-r--r--.1rootroot0Sep2216:36c.txt
file detection file type
#filec.txt
c.txt:ASCIItext
Text display command: catlessmore
cat displays file content
#cat/tmp/alert.log
less displays the file content line by line. The function of the less command is very similar to that of more. Both can be used to browse the contents of text files. The difference is that the less command allows the user to browse the file forward or backward, while the more command can only browse the file forward. Browse before.
When using the less command to display a file, use the PageUp key to page down and the PageDown key to page up. To exit the less program, press the Q key.
#less/tmp/alert.log
moreDisplay file content screen by screen
#more/tmp/alert.log
Text editing command: nano
nano is a character terminal text editor. It is much simpler than vi/vim and is more suitable for Linux beginners. (You can use the nano editor in the early stage, and you must be able to use vi in the middle and later stages, which is more common in Linux text control)
Sentence pattern:
nano file name
control:
Use Ctrl+O to save changes
Press Ctrl+X to exit
If you change the file, you will be asked if you need to save the changes. Enter Y to confirm saving, enter N not to save, and press Ctrl+C to cancel and return. If you enter Y Chinese linux operating system, the next step will ask you to enter the file name you want to save. If you do not need to change the file name, just press Enter; if you want to save it under another name (that is, save as), enter the new name and confirm. At this time, you can also use Ctrl+C to cancel the return.
ln: Shortcut method to create a directory or file
Construct a symbolic link file abc in the directory /usr/liu so that it points to the directory /usr/mengqc/mub1
ln-s/usr/mengqc/mub1/usr/liu/abc
The above is the detailed content of In-depth analysis of Linux directory structure: root directory, user directory, system configuration, etc.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The five basic components of Linux are: 1. The kernel, managing hardware resources; 2. The system library, providing functions and services; 3. Shell, the interface for users to interact with the system; 4. The file system, storing and organizing data; 5. Applications, using system resources to implement functions.

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

Linux devices are hardware devices running Linux operating systems, including servers, personal computers, smartphones and embedded systems. They take advantage of the power of Linux to perform various tasks such as website hosting and big data analytics.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.
