Compress files with bzip2, gzip, gunzip and tar — Cheat Sheet Linux

Bruno Delb
Open DevOps Academy
1 min readJul 11, 2022

--

bzip2

bzip2 <FILENAME> is used to compress files and directories. It has better performance than gzip. Be careful, it replaces the original files with the compressed files.

Example:

bzip2 /home/user/myfile.txt

gzip

gzip <FILENAME> and gzip2 <FILENAME> are used to compress files and directories. The original files are replaced by the new compressed version.

The arguments are:

  • -r (or --recursive): compresses files and directories recursively.

Example:

Compress the file myfile.txt and replace it with myfile.txt.gz:

gzip myfile.txt 

gunzip

gunzip <FILENAME> extracts the contents of a file compressed with gzip.

tar

tar <OPTIONS> <FILES> backs up and compresses files and directories using gzip or bzip. tar was originally used for tape backups. Multiple files can be specified by separating them with a space.

The arguments are :

  • -c (or --create): creates a new archive,
  • -t (or --list) : displays the content of the archive,
  • -x (or --extract) : extracts the content of the archive,
  • -f [<HOSTNAME>:]<FILENAME> (or --file) : specifies the name of…

--

--

Bruno Delb
Open DevOps Academy

Blockchains, DevOps, Agile Coaching, development, testing, Cloud, Management 3.0, ITIL. It defines me.