Skip to content

KALI – How to unzip files on Linux

16/07/2013

There are so many formats for unzipping, that it’s almost unfair. Here’s a tip – look at the ending of the file.

To unzip files that end with bz2 use

bunzip2 filename.bz2

*****

To unzip files that end with .tar.bz2 use

tar -xvjpf filename.tar.bz2

*******

To unzip files that end  .gz use

gunzip file.gz

or

gzip -d file.gz

*****

http://www.cyberciti.biz/howto/question/general/compress-file-unix-linux-cheat-sheet.php

Syntax Description Example(s)
gzip -d {.gz file}
gunzip {.gz file}
Decompressed a file that is created using gzip command. File is restored to their original form using this command. gzip -d mydata.doc.gz
gunzip mydata.doc.gz
bzip2 -d {.bz2-file}
bunzip2 {.bz2-file}
Decompressed a file that is created using bzip2 command. File is restored to their original form using this command. bzip2 -d mydata.doc.bz2
gunzip mydata.doc.bz2
unzip {.zip file} Extract compressed files in a ZIP archive. unzip file.zip
unzip data.zip resume.doc
tar -zxvf {.tgz-file}
tar -jxvf {.tbz2-file}
Untar or decompressed a file(s) that is created using tar compressing through gzip and bzip2 filter tar -zxvf data.tgz
tar -zxvf pics.tar.gz *.jpg
tar -jxvf data.tbz2

Linux Decompression Commands

How to extract various archives (tar, zip, gzip, bzip2 etc) on Linux and some other tricks for searching inside of archives etc.

COMMAND DESCRIPTION
unzip archive.zip Extracts zip file on Linux.
zipgrep *.txt archive.zip Search inside a .zip archive.
tar xf archive.tar Extract tar file Linux.
tar xvzf archive.tar.gz Extract a tar.gz file Linux.
tar xjf archive.tar.bz2 Extract a tar.bz2 file Linux.
tar ztvf file.tar.gz | grep blah Search inside a tar.gz file.
gzip -d archive.gz Extract a gzip file Linux.
zcat archive.gz Read a gz file Linux without decompressing.
zless archive.gz Same function as the less command for .gz archives.
zgrep 'blah' /var/log/maillog*.gz Search inside .gz archives on Linux, search inside of compressed log files.
vim file.txt.gz Use vim to read .txt.gz files (my personal favorite).
upx -9 -o output.exe input.exe UPX compress .exe file Linux.

Linux Compression Commands

COMMAND DESCRIPTION
zip -r file.zip /dir/* Creates a .zip file on Linux.
tar cf archive.tar files Creates a tar file on Linux.
tar czf archive.tar.gz files Creates a tar.gz file on Linux.
tar cjf archive.tar.bz2 files Creates a tar.bz2 file on Linux.
gzip file Creates a file.gz file on Linux.

*****

Options for tar files:

  1. Type at the command prompt
    tar xvzf file-1.0.tar.gz – to uncompress a gzip tar file (.tgz or .tar.gz)
    tar xvjf file-1.0.tar.bz2 – to uncompress a bzip2 tar file (.tbz or .tar.bz2)
    tar xvf file-1.0.tar – to uncompressed tar file (.tar)
    • x = eXtract, this indicated an extraction c = create to create )
    • v = verbose (optional) the files with relative locations will be displayed.
    • z = gzip-ped; j = bzip2-zipped
    • f = from/to file … (what is next after the f is the archive file)
  2. The files will be extracted in the current folder.  HINT: if you know that a file has to be in a certain folder, move to that folder first.  Then download, then uncompress – all in the correct folder.  Yes, I’m lazy.. no I don’t like to copy files between directories, and then delete others to clean up.  Download them in the correct directory and save yourself 2 jobs.

*****

Some time you just wanted to look at files inside an archive or compressed file. Then all of the above command supports file list option.

Syntax Description Example(s)
gzip -l {.gz file} List files from a GZIP archive gzip -l mydata.doc.gz
unzip -l {.zip file} List files from a ZIP archive unzip -l mydata.zip
tar -ztvf {.tar.gz}
tar -jtvf {.tbz2}
List files from a TAR archive tar -ztvf pics.tar.gz
tar -jtvf data.tbz2

https://highon.coffee/blog/linux-commands-cheat-sheet/

 

KALI – How to ZIP Files in Linux – The Visual Guide

https://uwnthesis.wordpress.com/2014/09/20/kali-linux-how-to-compress-files-in-linux-using-gzip-the-visual-guide/

*****

KALI – First things to do after installing Kali Debian Linux – The Visual Guide

https://uwnthesis.wordpress.com/2014/07/20/kali-first-things-to-do-after-installing-kali-debian-linux-the-visual-guide/

 

6 Comments
  1. visit this link to know the esiest method for extracting any type of file in kali linux

    Like

  2. Ade permalink

    and tgz files ?

    Like

    • Hi Ade,

      Okay, here we go.
      TGZ is the same as TAR.GZ files.

      tar xvzf archive.tar.gz
      Extract a tar.gz file Linux.

      tar xjf archive.tar.bz2
      Extract a tar.bz2 file Linux.

      Peazip is amazing.
      Easiest way to edit an uncompressed TAR is opening it in PeaZip and dragging files/folders to it, which will automatically activate update mode – can be changed into add mode in advanced tab.

      Like

Trackbacks & Pingbacks

  1. KALI Linux – How to Compress Files in Linux using GZIP – The Visual Guide | University of South Wales: Information Security and Privacy
  2. KALI – How to unzip files on Linux | soufianeneffar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: