This is the 8th day of my participation in Gwen Challenge
8. Search for lookup classes
8.1 the find
The basic grammar
Find [option]Copy the code
Option to show
options | function |
---|---|
-name< Query Mode > | Finds files according to the specified file name lookup mode |
-user< user name > | Find all files belonging to the specified user name |
-size< file size > | Find files based on the specified file size, in: B — Block (512 bytes) C – byte W — word (2 bytes) K — kilobytes M — megabytes G — gigabytes |
[root@hadoop1 test]# find./ -name b.testt [root@hadoop1 test]# find./ -user test123 ## +n > -n < n equal to [root@hadoop1 test]# find ./ -size -200cCopy the code
8.2 locate
The Locate directive quickly locates a given file using the LOCATE database of all file names and paths established in the system. The Locate command does not need to traverse the entire file system, resulting in faster queries. To ensure the accuracy of query results, administrators must periodically update locate time.
The basic grammar
Locate search fileCopy the code
Since the locate command is based on the database query, the first run must use the updatedb command to create the locate database/TMP directory
[root@hadoop1 ~]# updatedb
[root@hadoop1 ~]# locate .txt
Copy the code
8.3 the grep and |
Pipeline operators, “|”, said the previous command processing results of the output is passed to the back of the command processor
The basic grammar
The grep option finds the content source fileCopy the code
Option to show
options | function |
---|---|
-n | Displays the matching line and line number |
[root@hadoop1 test]# grep -n abc b.txt
[root@hadoop1 test]# ll | grep b
Copy the code
9. Compression and decompression classes
9.1 gzip/gunzip
The basic grammar
Gz gunzip file. Gz (Decompress the file)Copy the code
Tips (1) Compress only files but not directories. (2) Do not retain original files. (3) Multiple compressed packages are generated when multiple files are created at the same time
[root@hadoop1 test]# gzip b.txt
[root@hadoop1 test]# gunzip b.txt.gz
Copy the code
9.2 zip/unzip
The basic grammar
Zip Contents to be compressed (Function description: commands to compress files and directories) unzip [option] XXx. zip (Function description: Decompresses files)Copy the code
Option to show
Zip options | function |
---|---|
-r | Compressed directory |
Unzip options | function |
---|---|
– d < directory > | Specify a directory for storing decompressed files |
[root@hadoop1 test]# zip -r a.zip a.txt ./a
[root@hadoop1 test]# unzip a.zip
[root@hadoop1 test]# unzip a.zip -d ./a
Copy the code
9.3 the tar
The basic grammar
Gz Contents to be packed (Function description: Package directory, compressed file format.tar.gz)Copy the code
Option to show
options | function |
---|---|
-c | Generates a.tar package file |
-v | Display details |
-f | Specifies the compressed file name |
-z | Pack and compress simultaneously |
-x | Unpack the. Tar file |
-C | Decompress to the specified directory |
[root@hadoop1 test]# tar -zcvf b.tar.gz b.txt
[root@hadoop1 test]# tar -zxvf b.tar.gz -C ./bb
[root@hadoop1 test]# tar -zxvf b.tar.gz
Copy the code
10. Disk partition classes
10.1 df
The basic grammar
Df option (Function description: Lists the total disk usage of the file system and checks the disk space usage of the file system)Copy the code
Option to show
options | function |
---|---|
-h | Self-display in human-readable GBytes, MBytes, KBytes, etc |
[root@hadoop1 test]# df file system 1K- Block used Available Used % mount point devtmpfs 3993812 0 3993812 0% /dev//dev/vda1 41152736 21538252 17501000 56% / [root@hadoop1 test]# df -h File system capacity used Available Used % mount point devtmpfs 3.9g 0 3.9g 0% /dev........Copy the code
10.2 fdisk
The basic grammar
Fdisk -l (Function description: View disk partition details)Copy the code
Option to show
options | function |
---|---|
-l | Displays the partition list of all hard drives |
Tip: This command can be used only when the root user is running it
Linux partition Device: partition sequence Boot: Boot Start: starts from magnetic column X End: ends from magnetic column Y Blocks: capacity Id: Id of the partition type System: indicates the partition typeCopy the code
[root@hadoop1 test]# fdisk -l /dev/vda: Units = Sector of 1 x 512 = 512 bytes Sector size (logical/physical) : 512 bytes / 512 bytes I/O size (minimum/Best) : 512 bytes / 512 bytes Disk label type: DOS Disk Identifier: 0x000256f2 Device Boot Start End Blocks Id System /dev/vda1 * 2048 83886079 41942016 83 LinuxCopy the code
10.3 LSBLK
The basic grammar
LSBLK (View device mounting information)Copy the code
Option to show
options | function |
---|---|
-f | View detailed device mounting information and display file system information |
[root@hadoop1 test]# lsblk-f NAME FSTYPE LABEL UUID MOUNTPOINT vda ├ ─vda1 ext4 de91b9Ee-777-4a74-a22D-41669AC18c4a /Copy the code
10.4 Mount /umount Mounting/Unmounting
The basic grammar
Mount [-t vfstype] [-o options] Device dir (Mount device) umount Device file name or mount point (mount device)Copy the code
Parameters that
parameter | function |
---|---|
-t vfstype | Specifies the type of file system. Mount automatically selects the correct type. Common types are: CD or CD image: iso9660 DOS FAT16 file system: MSDOS Windows 9X FAT32 file system: VFAT Windows NT NTFS file system: NTFS Mount Windows file network sharing: SMBFS UNIX(LINUX) File network sharing: NFS |
-o options | This parameter describes the attaching mode of devices or files. Common parameters are: Loop: Used to attach a file to the system as a disk partition Ro: The device is mounted in read-only mode Rw: Connects to the device in read/write mode Iocharset: specifies the character set used to access a file system |
device | Equipment to be mounted |
dir | The mount point of the device on the system |