Skip to content

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

20/09/2014

Step 1 – Create Data

ls -l /etc > smile.txt

Check size of file

ls -l smile.*

My original filesize was 16119 (yours will be different – so keep a note of it).

gzip

 The zipped file will be automatically saved as  smile.txt.gz

******

Step 2 – Zip File

gzip smile.txt

Check file size

ls -l smile.*

Remember, the zipped file will be automatically saved as  smile.txt.gz

The compressed filesize is 3527 – which is a 78.2% compression in size.  Awesome!

gzip list stats

 

*****

Step 3 – Unzip File

gunzip smile.txt

Check file size

ls -l smile.*

Check that the filesize is exactly equal to the original filesize…. it should be exactly the same.

 

*****

Step 4 – Only view Contents of a zipped file

gunzip -c smile.txt | less

zcat smile.txt.gz | less  **Zcat is supplied with gzip automatically.

zless smile.txt.gz

****

Facts about Compression

  • Data compression is about removing redundancy from data.
  • An image that is all one colour contains entirely redundant data.
  • Compression is lossless or lossy.
  • Lossless preserves the original data – the original can be recreated.
  • Lossy removes data – the original can not be recreated – only an approximate is restored.
  • Examples of Lossy are JPEG (Images) and MP3 (Music).

gzip compression stats

 

****

gzip Command Codes

gzip -c = write to standard output and KEEP original files

gzip -d = DECOMPRESS.  Or we can use gunzip.

gzip -f = FORCE compress, even if a compressed version of the file already exists.

gzip -h = Display usage information.

gzip -l = LIST compression statistics.

gzip list stats

 gzip -r = where directories exist, RECURSIVELY compress files within those directories.

gzip -t = TEST the integrity of a compressed file.

gzip -v = VERBOSE – but you already knew that.

gzip -number = Set AMOUNT OF COMPRESSION.  Number is an integer between 1 and 9.

The DEFAULT VALUE is 6!!!. 

1 is the FASTEST – with LEAST COMPRESSION

9 is the SLOWEST – with MOST COMPRESSION

–fast and –best can be used.

******

Here we attempt MAX compression ratio’s = which achieves a compression rate of 78.7%

gzip -9 smile.txt

gzip max compression

References:

University South Wales reading list.

SHOTTS, W.E., 2012.  The Linux Command Line.  San Francisco: No Starch Press.

 

KALI – How to unzip files on Linux

https://uwnthesis.wordpress.com/2013/07/16/kali-how-to-unzip-file-on-linux/

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: