1.1 Linux system directory structure, relative path/absolute path
1.1.1 Linux System directory structure
Everything in the Linux system is a file.
/ root directory, the beginning of everything, like a branch, he is the root of all forks
/bin
In single-user mode, the common Linux commands you need to use are located in this directory. The commands used by all users of the system are set here.
For example: PS, ls, ping, grep, CP
/sbin
Just like/bin,/sbin also contains binary executables.
However, Linux commands in this directory are usually used by system administrators to maintain the system. Example: Iptables, reboot, Fdisk, ifconfig, swapon commands
/boot
The files that need to be loaded when the system starts are here
/ dev storage device files are also seen as files in the Linux system North
/ etc Store system configuration file, and program configuration file
There are many, according to the English name can know its configuration purposes
such as ABRT---interrupt environment environment
/etc/environment is the environment that sets up the entire system, and/etc/profile is the environment for setting up all users, regardless of the login user, which is related to the logged-on user
Home for all ordinary users, storing data for ordinary users
/root The Super User's home, storing the Superuser's data
/lib System library files have static library and dynamic library program compile and run rely on
/lib64 System 64-bit library file
/media Removable multimedia device
/mnt for mounting
/opt This casual use
/proc can view system status
Contains information about the system process.
This is a virtual file system that contains information about the processes that are running. For example: The/proc/{pid} directory contains information related to a specific PID.
This is a virtual file system in which system resources exist as textual information. Example:/proc/uptime
Cat Meminfo #查看内存使用状态
Cat Cpuinfo #查看cpu运行状态
/run
Well, I'm not quite sure what he's storing, and it looks like the system running state.
Now know that its predecessor was/var/run
/srv
The SRV Representative service.
Contains data related to server-specific services.
For example,/srv/cvs contains CVS-related data.
/sys
Fixed information that should be stored on the system hardware
/tmp
Contains system and user-created temporary files.
When the system restarts, the files in this directory will be deleted.
/usr
Source code that contains binaries, library files, documents, and level two programs.
The/usr/bin contains a binary file of the user program. If you can't find the user binaries in/bin, go to the/usr/bin directory to see. For example: At, awk, CC, less, SCP.
The/usr/sbin contains the system administrator's binaries. If you can't find the system binaries in/sbin, go to the/usr/sbin directory to see it. For example: ATD, Cron, sshd, Useradd, Userdel.
The/usr/lib contains the libraries used by/usr/bin and/usr/sbin.
The user program installed from the source is included in the/usr/local. For example, when you install Apache from the source, it will be in/usr/local/apache2.
/var
var represents a variable file.
This directory allows you to find files that may grow in content.
This includes-system log files (/var/log), Package and database files (/var/lib), e-mail (/var/mail), print queue (/var/spool), lock Files (/var/lock), multiple restarts of required temporary files (/var/tmp) ;
1.1.2 Relative Path/absolute path
Relative paths are relative to the current position, so generally. Or.. Beginning
The absolute path is relative to/, so it is usually preceded by/
Very well differentiated
1.2 Create/Copy/delete files, RM-RF/accidents
1.2.1 Create: Touch
Format: Touch file name
Example: Touch a.txt
1.2.2 Copy: CP
Format: CP source file target file #可带路径
Add parameter-rf to copy directory
-R Recursive Replication recuursively
-F does not prompt force
1.2.3 Delete: Rm/rmdir
Format: RM target file
rm-d Directory Name
-d The file to be deleted is an empty directory
Adding the-RF parameter can also be deleted unless an empty directory
-r-f meaning with CP
1.2.4 Rename/move: MV
MV original filename new file name #重命名
Add a path to the file name to experiment with moving
Such as:
MV A.txt bbb.txt #将文件a. txt renamed to Bbb.txt
MV A.txt/root #将a. txt moves to the/root directory
1.3 Viewing the contents of a file
Cat file name
More File name | Less file name
If the file text is more, you can use these two commands to view, distinguish yourself research it
Head File name | Tail file name
View file header or end of file
Add-n parameter to view the file header n rows or the reciprocal n rows
To view a row of a file individually, you can use the channel
Example: View line 3rd of the A.txt file
Head-3 A.txt | Tail-1
1.4 Combat: Backup and Recovery of XFS file systems
First step: Shut down the system first, add a hard disk
The rest of the way by default, then click OK, then boot
Step two: View the file name of the newly added hard disk as SDB and partition the SDB
Follow the instructions on the command prompt:
Enter N to add a new partition
Enter p to create a primary partition
Number and location default, direct carriage
Enter the new partition size of 1G, which is input +1g, enter,
Enter W to perform partition operation, partition new
Step three: Format the newly created partition, using the MKFS.XFS
You can also use the Mkfs-t xfs/dev/sdb1 command
Fourth step: Mount the/DEV/SDB1 partition
Fifth step: Copy a file to the/SDB1 directory, create a new directory into the/SDB1 directory and leave it for testing
Sixth step: Backing up the file system
[Email protected] ~]# xfsdump-f/OPT/DUMP_SDB1/DEV/SDB1
xfsdump:using file Dump (drive_simple) strategy
Xfsdump:version 3.1.4 (Dump format 3.0)-type ^c for status and control
============================= Dump Label Dialog ==============================
Please enter the label for the dump session (timeout in SEC)
dump_sdb1_20160802
Session label entered: "dump_sdb1_20160802"
---------------------------------End Dialog---------------------------------
Xfsdump:level 0 Dump of XIAOGAN.120:/SDB1
Xfsdump:dump Date:tue 2 23:56:53 2016
Xfsdump:session id:d850eaf1-d2f6-4a3e-b694-0a9547017754
Xfsdump:session Label: "dump_sdb1_20160802"
Xfsdump:ino map Phase 1:constructing initial Dump list
Xfsdump:ino map Phase 2:skipping (no pruning necessary)
Xfsdump:ino Map Phase 3:skipping (only one dump stream)
Xfsdump:ino Map Construction Complete
xfsdump:estimated dump size:25536 bytes
Xfsdump:/var/lib/xfsdump/inventory Created
============================= Media Label Dialog =============================
Please enter the label for media on Drive 0 (timeout in sec)
media0
Media label entered: "Media0"
---------------------------------End Dialog---------------------------------
Xfsdump:creating dump Session Media file 0 (media 0, file 0)
xfsdump:dumping ino Map
xfsdump:dumping Directories
xfsdump:dumping non-directory Files
Xfsdump:ending Media file
Xfsdump:media File size 24232 bytes
Xfsdump:dump size (non-dir files): 2592 bytes
Xfsdump:dump complete:23 seconds Elapsed
Xfsdump:dump Summary:
Xfsdump:stream 0/opt/dump_sdb1 OK (Success)
Xfsdump:dump status:success
To view backup information:
You can also back up in a non-interactive way, with the following commands:
Xfsdump-f/opt/dump_sdb1/dev/sdb1-l dump_sdb1_20160802-m media0
-f Specifies the backup file directory
-L Assign Label session label
-m Specify Device label media label
Single File backup:
The-s parameter can back up a single file, but
Xfsdump-f/opt/dump_passwd-s/sdb1/passwd-l dump_passwd-m passwd
-S cannot be followed directly by the path, it should be the following:
Xfsdump-f/opt/dump_passwd-s passwd/sdb1-l dump_passwd-m passwd
Seventh Step: File Recovery, delete file manufacturing false Delete illusion, and then use the Xfsrestore command to recover files
Command: Xfsrestore-f/opt/dump_sdb1/sdb1
Recover individual Files!!!
Basic management of the sixth day file and XFS system backup recovery