Common Compression Instructions on Linux and Unix

 Below we will list a few common compressed file extensions.
  • *.Z compress program compressed files;
  • *.zip Files compressed by the zip program;
  • *.gz files compressed by gzip program;
  • *.bz2 The file compressed by the bzip2 program;
  • *.xz xz program compressed file;
  • *.tar The data packaged by the tar program has not been compressed;
  • *.tar.gz tar program packaged files, which are compressed by gzip
  • *.tar.bz2 tar program packaged files, which are compressed by bzip2
  • *.tar.xz tar program packaged files, which are compressed by xz

 

1. gzip, zcat/zmore/zless/zgrep

Currently gzip can unzip files compressed by compress, zip and gzip.

By default, the original file will be compressed into a .gz file name, and the original file will no longer exist.

Compress and prints the compression ratio:
$ gzip -v  service
services:        79.7% -- replaced with services.gz

Decompress:
$ gzip -d service.gz

Compress with the best compression ratio and keep the original file:
$ gzip -c -9 service > service.gz
 

-v, --verbose  This option turns on verbose mode, which prints the
                       compression ratio for each file compressed.

-d, --decompress, --uncompress  This option selects decompression rather than
                       compression.

-c, --stdout, --to-stdout  This option specifies that output will go to the
                       standard output stream, leaving files intact.

-1, --fast
-2, -3, -4, -5, -6, -7, -8
-9, --best  These options change the compression level used, with
                       the -1 option being the fastest, with less compression,
                       and the -9 option being the slowest, with optimal
                       compression.  The default compression level is 6.

More details man gzip.

2. bzip2,bunzip2,bzcat,bzip2recover

bzip2, bunzip2 - a block-sorting file compressor
bzcat - decompress files to stdout 
bzip2recover - recovers data from damaged bzip2 files

$ bzip2  [-cdzkv123456789]  [filenames ...]
$ bzcat  filename.bz2

-c --stdout  Compress or decompress to standard output.
-d --decompress
-z --compress
-k --keep  Keep (don't delete) input files during compression or decompression.
-v --verbose
-1 (or --fast) to -9 (or --best)  Set the block size to 100k, 200k, .. 900k when compressing.

More details man bzip2


3. xz,unxz,xzcat,lzma,unlzma,lzcat 

SYNOPSIS
       xz [option...] [file...]
       xz [-zdtlkc0123456789]  [file...]   
       -z, --compress  Compress.
       -d, --decompress  Decompress.
       -t,  --test   Test the integrity of compressed files.
       -l,  --list     Print information about compressed files. 
       -k, --keep  Don't delete the input files.
       -c, --stdout   Write the compressed or decompressed data to standard output instead of a file.   
       -0 ... -9  Select a compression preset level. The default is -6. 

More details man xz.




Comments

Popular posts from this blog

BdsDex: failed to load Boot0001 "UEFI BHYVE SATA DISK BHYVE-OABE-20A5-E582" from PciRoot(0x0)/Pci (0x2, 0x0)/Stat(0x0,0xFFFF,0x0) : Not Found

How To Install Nginx, MySQL and PHP (FEMP) Stack on FreeBSD 13.0

Install samba on FreeBSD(on VMware Workstation) to share files with Window.