Previous section review:
1. Locate command
2. Whereis,which command
Job: Create a file myfile.txt, find it with locate, and find the CD command with which and Whereis, respectively
Touch MyFile.txt
Locate MyFile.txt
UpdateDB
Locate MyFile.txt
Whereis CD
which CD
1. gzip/gunzip
Gzip is used to compress files in place, it is simple to use, for example, we want to compress the messages file under/var/log, can be used directly with GZIP messages
You can find that the messages file does not exist, one more messages.gz file
At the same time we use Gzip messages.gz–l to view the zip file details
We can see that the compression ratio is 87.3% or quite impressive.
To unzip a newly compressed file, you can use Gunzip
Gzip can only be used to compress files, cannot compress directories, can use GZIP–H to see more parameter description
2. tar
The tar command can not only package files but also package directories, and it can also use the compression feature of Gzip.
For example, the most general usage of this command, such as packing the log directory, can be used
TAR–ZCVF Log.tar.gz/var/log
The parameters here, Z, are compressed with gzip, c means the file is created, v indicates the compressed file is displayed, and F indicates the use of the filename.
To unzip the file you just created, use TAR–ZXVF Log.tar.gz–c/tmp/log
Job: Compress the Lastlog file under/var/log with gzip, then unpack it with gunzip, and pack the ETC directory into the TMP directory with tar
Follow the public number "kick genius" for a full video + graphics tutorial
Linux Command Learning Series 13-gzip,tar command