Home >System Tutorial >LINUX >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!