There are several ways to compress under Linux: gzip, bzip2, XZ, zip
Gzip
The compressed file ends in. GZ,
Only files can be compressed and directories cannot be compressed
Usage:
Gzip:/path/to/somefile is used to compress, the original file will be deleted when finished
-D Decompression
-#: 1-9 To specify compression ratio eg:-9
Gunzip/path/to/somefile used to decompress, delete the original compressed file when finished
Zcat ZipFile Viewing compressed file contents
BZIP2:
The compressed file ends with a. bz2
Only files can be compressed and directories cannot be compressed
A greater compression ratio than gzip, only files can be compressed, folders cannot be compressed
Same as GZIP usage
-K can retain the original file when compressing,
Bzcat ZipFile Viewing compressed file contents
Zip:
Can compress the directory
Usage:
Zip compressed file name to compress files 1, files to compress 2
Unzip the file name to unzip
Do not delete the original file
Archive operations under Linux use the TAR command
Archiving is to put several files in a file with a. tar suffix
Usage: TAR-CF filename.tar file1,file2 .... Used to archive files
TAR-XF Filename.tar do not expand the archive and directly view which files are archived
-C: Create an archive file
-F File.tar Generated archive file
-X Expand Archive file
--xattrs: Preserves extended attribute information for files when archiving
-T: Do not expand the archive to directly see which files are archived
Tar can call each of the compression command implementations to both archive and compress.
-ZCF: Archive and invoke gzip compression
-ZXF: Call gzip to unzip and expand the archive, the-Z option can be omitted because the tar command can identify the compression tool used by the archive file according to the file suffix name (previous-can be omitted)
Similarly:-JCF: Call bzip2 Archive
-JXF: Call bzip2 Extract
Linux compression and archiving