Beginner Linux second lesson

1. The directory structure of the linux file system:
linux directories (files) are logically organized into an inverted single-rooted tree structure, with "/" as the root and extending downwards, with the characteristics of upper and lower levels;
Take CentOS 8 64-bit 1905 version as an example:
Beginner Linux second lesson

But from the perspective of physical storage location, the entire directory structure can be stored across hard disks and partitions;
although in terms of logical organization structure, the /boot and /data directories are both subordinate directories of the root directory "/", but from the physical storage In terms of location, they are at the same level as the root directory "/" directory, which is a separate partition:
Beginner Linux second lesson
Take CentOS 8 64-bit 1905 version as an example to explain the role of each directory:
bin -> usr/bin (basic User command binary file (for all users), this directory is actually a soft link file on CentOS8, actually pointing to the usr/bin directory)
boot (static file of the boot loader)
data (user sub-defined directory (optional) )
Dev (device file)
etc (system configuration file directory)
home (user home directory (optional))
lib->usr/lib (basic shared library and kernel module, this directory is actually a soft link file on CentOS8, Actually points to the usr/lib directory)
lib64->usr/lib64 (dedicated to the storage directory of shared library files on X86_64-bit systems, this directory is actually a soft link file on CentOS8, which actually points to the usr/lib64 directory)
media (device Mount point)
mnt (device mount point)
opt (installation location of third-party applications)
proc (used to store virtual files that output information about the kernel and processes on the current system)
root (administrator home directory)
run (running The relevant data of the program is the same as that in /var/run/)
sbin->usr/sbin (basic management commands, this directory is actually a soft link file on CentOS8, which actually points to the usr/sbin directory)
srv (data used by services running in the system)
sys (virtual files used to store and output information about hardware devices on the current system)
tmp (directory for storing temporary files)
usr (full name is unix shared resources, storing many applications of users Programs and files)
var (stores constantly changing files, such as system log files, etc.)
Reference website: https://www.pathname.com/fhs

2. File metadata information
File metadata information includes file node number, file size, file type, permission, user, user group, link number,
time stamp (including access time atime, metadata change time ctime,
The file content change time mtime (when the ll command is used to view the file, the displayed time is mtime))
, the data block pointer pointing to the file data on the disk, and other data related to the file itself; this
information is stored in the inode table through stat "File name", you can view the metadata information of the file.
Example:
Beginner Linux second lesson
use touch -a "file name" to change atime and ctime.
Example:
Beginner Linux second lesson
use touch -m "file name" to change mtime and ctime.
Example:
Beginner Linux second lesson
3. Hard link and soft link
(to create a new file, there are two actions: one is to create a file name, and the other is to create a file)
1. A hard link is essentially to take a new file name for the source file and not to create a new file , The new file name points to the source file;
2. The soft link, in essence, is to create a new link-type file and point this link-type file to the file name of the source file;
3. The difference between a hard link and a soft link:

Comparison item Hard link Soft link
Relationship with source file Same file Different files
Establish links across devices not support stand by
Node number Same as source file Different from the source file
Number of source file links change constant
Create a link to the folder not support stand by
relative path The relative path of the source file is relative to the current working directory The relative path of the source file is relative to the relative path of the linked file
The effect of deleting source files on links The number of links is reduced by one, which does not affect the access to the source file through the linked file Linked files will not be able to access source files
file type Same as source file Link type file, independent of source file

Example:
Create a new file and write content to the new file:
Beginner Linux second lesson
Create hard and soft links
Beginner Linux second lesson
for the file : View brief information about the linked file:
Beginner Linux second lesson
Verify the effect of accessing the source file through the link by viewing the source file, hard link file, and soft link file;
Delete the source file (actually just the file name) and verify the effect of accessing the source file through the link:
Beginner Linux second lesson

4. File management commands on
Linux File management commands on Linux include create, copy, move, delete, batch rename, etc.
(1) Create a file
touch [OPTION] FileName
common options:
-a Only modify the atime and ctime of the file.
-c Do not create non-existent files.
-m only modify the mtime and ctime of the
file -r file use the timestamp (atime and ctime) of the specified file to update the timestamp (atime and ctime) of the file
-t modify the time to the date specified by the parameter, [[CC]YY ]MMDDhhmm[.ss]
(2) Copy files
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE
common options:
-i if The target exists, prompt before overwriting (to invalidate the previous -n option)
-n Do not overwrite the existing file (to invalidate the previous -i option)
(When using -i and -n, pay attention to the order of the two, the latter is valid )
-F If the target exists, do not prompt when overwriting the target file
-R, -r Recursively copy all directories and all contents in the directory
-a Archive, used for backup, equal to -dR --preserve=all
-d: equal to- -no-dereference --preserve=links, do not copy the source file, only copy the link name
-b: If the target exists, back up before overwriting, the default format is FileName~
--backup=numbered If the target exists, back up before overwriting, backup name FileName.~#~, you can back up multiple versions
(3) Move File
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE
Common options:
-i If the target exists, prompt before moving (make the previous -n option is invalid)
-n if the target exists, do not move (make the previous -i option invalid)
-f if the target exists, then move without prompt
-b: If the target exists, backup before overwriting, the default format is File~
(3) Delete file
rm [OPTION] File/DIRECTORY
common parameters:
-i prompt
-f to force deletion
when deleting , no prompt -r When the deleted object is a directory, and there are directories in the directory, delete the object recursively All goals

Guess you like

Origin blog.51cto.com/5277813/2667552