Linux decompression and compression instructions

gzip compressed files, gunzip decompressed files

After compressing the file, the original file is not saved.
gzip hello.txt
Unzip the file, and the original compressed file does not exist.
gunzip hello.txt.gz

zip and unzip instructions

zip is used to compress files, unzip is used to decompress, this is very useful in project packaging and release

zip [option] xxx.zip
unzip [option] xxx.zip

Compress the files under the home file, -r recursively compresses, that is, compress the directory
zip -r mypackage.zip /home/

-d unzipped directory
unzip -d /opt/tmp/ mypacage.zip

tar instruction packing instruction

tar [options] xxx.tar.gz
-c produces .tat packed files
-v displays detailed information
-f specifies the compressed file name
-z packs and compresses
-x unpacks .tar files

Compress multiple files, compress /home/a1.txt and a2.txt into a.tar.gz, compress files in
tar -zcvf a.tar.gz a1.txt a2.txt
/ home directory
tar -zcvf myhome.tar.gz /home/

Unzip the current directory
tar -zxvf a.tar.gz

Unzip to the specified directory, this directory must exist
tar -zxvf myhome.tar.gz -C /opt/

Published 48 original articles · Likes0 · Visits 282

Guess you like

Origin blog.csdn.net/qq_44971387/article/details/105330469