Unix 101 / Unzipping Files

All of the below commands assume that you are within the same directory that the compressed file is in. To be sure type:
ls {enter}
If the file is there, you�re ready to go. If not type:
cd /big/dom/xdomain/www/directory/ {enter}
replacing the path with the correct path to your file.

If a file ends in .zip (for example, file.zip) type:
unzip file.zip

If a file ends in .tar (e.g., file.tar) type:
tar -xvf file.tar

If a file ends in .gz (for example, file.gz) type:
gzip -d file.gz

If a file ends in .tar.gz (e.g. file.tar.gz) type:
gzip -d file.tar.gz
and then
tar -xvf file.tar

If a file ends in .tgz (e.g. file.tgz) type:
tar -xvzf file.tgz

If file end in .bz2 type:
tar -xvfj file.tar.bz2
Thanks to http://www.aota.net/Telnet/unzip.php4

This entry was posted in Linux. Bookmark the permalink.

5 Responses to Unix 101 / Unzipping Files

  1. Gare says:

    If it’s .tar.bz2, then you can use
    Code:

    tar xjvf cornbread.tar.bz2

    to extract it all at once. If it’s just .bz2, then use
    Code:

    bunzip2 spankythefish.bz2

  2. Gare says:

    To tar & zip on RH:

    tar cvzf /home/ghome/myfiles.tgz myfilesdirectory

  3. Manuel says:

    For zip:

    If you want extract and override all old files and creating the new files… try this:

    unzip -uo joomla_update.zip

    Where:

    joomla_update.zip is your .zip file.

  4. gbviswanadh says:

    dear sir am working in linux os and i want to know how to extract file which are in for example abcd.zip.bz2 like that how i cant extract zip file, i know bizp2 -fd abcd.zip.bz2 and after that unzip abcd.zip, so is there any another command is there to unzip file

  5. gare says:

    hello gbviswanadh,

    The -j switch of tar command handles bzip2 files. So to unzip a .bz2 file use tar like this:

    tar -xvfj file.tar.bz2

    This should unzip the bzip2 zip, then extract the tarred file.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>