Some times you need to create zip a file and unzipping the file, also some time you need to UNRAR a file in Ubuntu using Terminal, So here is the simplest way to do so. You can zip a file using ubuntu terminal just use these simple command lines.

UnRAR a File in ubuntu

  1. First i need to run
    sudo apt-get install unrar
    to install unrar.
  2. If i want to unpack all files within the .rar files in the same directoryunrar e -r /home/work/software/myfile.rar
  3. if i want to unpack the files in full pathunrar x -r /home/work/software/myfile.rar

Make Zip and Unzip a File

If you do not have the packages installed yet, you need to

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

Happy “zipping”!