Compression and decompression of Linux commonly used commands -tar
tar
tar is a commonly used compression and decompression command. You can use the tar command to pack files, and the typed out package usually becomes a tar package; you can also use the tar command to decompress the compressed packages ending in .tar and .tar.gz.
Interlude : In
the process of learning, I found that packaging and compression are two different concepts. Here is a brief description. Packaging refers to turning some files into a total file and tying them into a package, that is, a tar package; compression refers to turning a large file into a small file through a compression algorithm.
Common parameters
- -c: pack or compress
- -x: unzip
- -z: with gzip attribute
- -v: display all processes
- -f: Specify the backup file, this is the last parameter
Common commands
-
Packaging :
tar -cf xxx.tar 1.txt //Pack 1.txt as xxx.tar
tar -cvf xxx.tar 1.txt //Pack 1.txt as xxx.tar, and display all the processes at the same time -
Compression :
tar -czf xxx.tar.gz //Pack 1.txt into xxx.tar, and compress it with gzip to generate a compressed package named xxx.tar.gz -
Unzip :
tar -xf xxx.tar //unpack xxx.tar
tar -xvf xxx.tar //unpack xxx.tar, and display all the processes
tar -zxvf xxx.tar //unzip xxx.tar.gz and display at the same time All processes
tar -zxvf xxx.tar -C /data/file //Unzip xxx.tar.gz to the specified directory, and display all processes at the same time -
Supplement :
tar -tf xxx.tar //List all files in the xxx.tar package, -t means to list files