Compression & Decompression on Linux

Ref: https://askubuntu.com/a/660865

sudo apt-get install zip gzip tar

first (or by a graphical pkg-manager).

Then, for an entry it would be the easiest way to use zip/unzip:

zip -r my_arch.zip my_folder

where -r means “recursive”.

To unzip you simply use

unzip my_arch.zip

Zip stores relative path names by default. There are several parameter-options available for zip. For that read: the manual (man zip). For a starting this will do.

Most often you will see .tar.gz endings in linux-world. That’s the product of two tools: TAR (the tape archiver) and GZIP (the GNU-Zip). Tar has got the call option to automatically gzip/gunzip files after “taring”.

tar -cvzf may_arch.tar.gz my_folder

where

  • -c means “create”
  • -v means “verbose” (sometimes bothersome and slowing down…)
  • -z means “use (GNU)zip”
  • -f XYZ declares the name of the output file. (You should chose a helping name like XYZ.tar.gz)
    There may also be .tar.bz2 endings. This is the product of the -j parameter instead of the -z parameter: you will choose compression with BZIP2 (-> man bzip2).

To extract you simply use -x (eXtract) instead of -c (Create):

tar -xvzf may_arch.tar.gz