Compression and decompression command gzip, bzip2, tar

1. gzip

Description: compression and decompression

Usage: gzip [options] ... [file name] ...

Options: -d decompression

After gzip hello.txt # compressed file named hello.txt.gz

gzip -d hello.txt.gz # decompress gz file

2. bzip2

Description: compression and decompression

After bzip2 hello.txt # compressed file named hello.txt.bz2

bzip2-d hello.txt.bz2 # decompress gz file

Note: gzip and bzip2 tool not to do catalog compression packing operation

3. takes

Description: Packaging and unpacking files

Usage: tar mode [options] [path] ...

Mode: -c create a package file

   --delete delete files from the archive file

   -r append files to package file

   -t lists the contents of the package file

   -x release package file

Options: -C specify an extraction location

   -z gzip format compressed by the packing

   -j bzip2-compressed by the packing 

   -v display process execution instruction

   -f specify the file name of the package

   After --remove-files package to delete source files

tar -cf etc.tar / etc / # the / etc / directory package saved as etc.tar

tar -czf boot.tar.gz / boot / # the / boot directory packaged and compressed into etc.tar.gz

tar -cjf etc.tar.bz2 / tmp / # the / tmp / directory packaged and compressed into etc.tar.bz2

tar --delete etc / hosts -f etc.tar # deleting files from the archive file hosts

tar -f etc.tar -r /root/install.log # append files to package file in etc.tar

tar -tf boot.tar.gz # View information package file file

tar -tvf etc.tar # to view details of the package file file

tar -xzf boot.tar.gz # decompress gz file format package to the current directory

tar -xjf etc.tar.bz2 # decompression bz2 format package file to the current directory

tar -xzf boot.tar.gz -C / tmp # specify an extraction location is / tmp

tar -czf mess.tar.gz / var / log / messages --remove-files # Delete files after compression packing

Guess you like

Origin www.cnblogs.com/opsprobe/p/11617815.html