Sunday, May 1, 2011

Linux#3: Extracting RAR files and Tarballs

 ========== EXTRACTING .RAR FILES IN UBUNTU  =============

By default, Ubuntu's compressed files are tar balls (file.tar)
and often times are packaged further to be file.tar.gz or .tar.bz2
(this is conceptually equivalent to having a .zip in a .rar in Windows)

Anyways, .rar is a proprietary compression/archiving method and
Ubuntu cannot handle these types of file by default.
You must DL "unrar" and then unrar the file via the terminal.

$>sudo apt-get install unrar

Unrar is easy to use... just type "e" as a command to tell it
to extract the contents of the RAR file to the current directory...

$>sudo unrar e NAME_OF_FILE

And BAM, you're done...
========== EXTRACTING TARBALLS IN UBUNTU =============

IF you have an tarball, you should just be able to right click it and choose "extract here"
or "extract to..." and select a location and it will do it for you.
However, if it IS packaged twice, and you have SEVERAL .tar files after you open
and extract it the first time from tar.gz/tar.bz2, you can use the command line method
of using an asterix and the command tar to untar ALL files with a given extention.

****NOTE:**** This is because in linux, an asterix refers to ALL files... so *.jpg would refer to Anything with a ".jpg" extension... an example that you should already understand is the command to delete files, "rm"... you can use it with the "*" to delete all files of a certain type by doing "rm *.gif". This would delete ALL GIFS in your current directory. ****/NOTE****

Anyways, if you have a tar.bz2 that WILL give you many TAR files you need to extract at once, do the following from the original single file:

$>sudo tar -xjf whatever.tar.bz2 -C /path/to/destination_folder

// goto /path/to/destination-folder

$>sudo tar -xjf *.tar

So much WinRAR!


  1. I always wondered when people actually used .tar, and now I know :)

  2. Thanks for all the info. great post. following.

  3. Unzipping always confused me. Thanks for the info!

  4. I read you previous posts and they just get more interesting and interesting
    How to Hack Life.