1. Mounting storage media
The Linux file system incorporates all the disks into a single virtual directory, which needs to be placed in the virtual directory before the new storage media is used, which is called mount (mounting)
1.1 Mount Command
The command to mount the media on Linux is called Mount. By default, the Mount command outputs a list of mounted devices on the current system.
1.2 Umont
To remove a removable device, you cannot remove it directly from the system, and you should uninstall it first. Use the Umont command (later in the demo).
2. View disk space
In Linux systems, it is important to monitor the disk usage of the system. Know how much space is available for the program to use. The following are common commands for disk Management.
2.1 DF Command
Using the DF-H parameter outputs the system disk space information, which is displayed in an easy-to-read format.
2.2 du command
Use the DU-H command to display disk usage for the current directory, determine how much storage space is being consumed, and whether there are large files.
3. data processing
3.1 Search Data grep
The PS command is described in the previous section when viewing the process with the grep command mentioned. The following shows the MySQL error log file to find information that contains warning keywords.
Use the GREP-C parameter to display the number of matches, the following matches the number of warning keywords 50.
3.2 Compressed Data gzip
In Windows, it is often useful to compress files, such as zip files, into smaller files that occupy less space. The compression tools in Linux include the following: Bzip1 extension. bz2; The compress extension is. Z gzip extension. gz; The zip extension is. zip. A common compression tool is the GZIP tool.
Gzip: Used to compress files, Gzcat: Used to view compressed text file contents. Gunzip: Used to extract files.
Following the use of gzip compressed Mariadb.log file, note that after compression, the original file does not exist.
Use Gunzip to unzip the mariadb.log.gz package .
The face is larger than the pre-and post-compression byte occupancy.
3.3 Archive Data tar
The zip command described above provides a good way to compress and archive data into a single file, but the most widely used archive tool in Linux is the tar command.
Here's a look at the format of the tar command:tarfunction [options] Object1 object2.
Include functional parameters and option parameter two in the TAR command. When used, it is usually used in conjunction with the function parameters and option parameters.
Function |
Describe |
-A--concatenate |
Append an existing tar archive file to another existing tar archive |
-C--create |
Create a new tar archive file |
-D--delete |
Remove from existing tar archive files |
-R--append |
Append a file to the end of an existing tar archive file |
-T--list |
List the contents of an existing tar archive file |
-U--update |
Appends a new file with the same name as the one already in the TAR archive file to the TAR archive |
-X--extract |
Extracting files from existing tar archive files |
Options |
Describe |
-C dir |
Switch to the specified directory |
-F File |
Output results to File |
-j |
REDIRECT output to the bzip2 command to compress content |
-P |
Keep all file permissions |
-V |
Show files when working with files |
-Z |
REDIRECT output to the gzip command to compress content |
The following is a demonstration of the tar command and the combination of parameters (functions and options), taking Mariadb.log and mariadb.log2 under/VAR/LOG/MARIADB as an example.
(1) Use the TAR-CVF combination to create an archive empty package named Mariadb.tar, and add the Mariadb2.log file to Mariadb.tar.
(2) Use the TAR-TF command to view the contents of the archive package.
(3) Use the TAR-XVF command to extract the contents of the archive package, The following demo first deletes the mariadb2.log and then removes it from the Mariadb.tar to the current directory (note that if the archive is not a file but a directory, the extraction will be the root directory, recreated in the current directory).
The current directory file is listed below and you can see that mariadb2.log is extracted from the archive.
(4) Use TAR-ZXVF to extract file names ending with. tgz (download open source software, typically files ending in. tgz). For example, the MySQL binary package that we downloaded is the tar.gz file, which is a tar file that has been compressed by gzip.
The Tar-zxvf command is generally usedto extract and extract
the file tar -zxvf mysql-5.7. -LINUX-GLIBC2. -x86_64. Tar
Summary: There are many combinations of features and options for tar, such as the ability to archive mariadb.log to Mariadb.tar, so that the Mariadb.tar file contains Mariadb.log and Mariadb2.log. For example, use the-D feature parameter to remove a file from the TAR archive package. With tar, you can easily archive your entire directory into a single tar file package, allowing you to migrate your data to another system.
Linux Programming 8 (Mount mount, view disk df Du, search grep, compress ZGIP, archive tar)