Zipping and Unzipping Files

One of Windows' most popular utilities is the compression program WinZip. This handy program lets you group a bunch of files together and compress them into one smaller file. This smaller file size means little when you consider the large hard drive capacities most computers have today, but it can be a real blessing when you want to send a lot of files, like all the pictures of your wedding, to friends and family via email. Also, you often need to unzip programs you download from the Internet before you can install them. This is true for both Windows and Linux.

Linux has long had the ability to zip and unzip files. In fact, it has several programs, both command-line and GUI, to perform these tasks. Some of them use the same compression algorithm used by WinZip, while others use a free variant. I'll explain how to use both types of programs.

Let's pretend that you've received an email from your sister, with a zipped attachment containing pictures of your nephew's first birthday party. Though you could open this attachment and view the files using Konqueror (covered in Chapter 3), let's use the command line instead. Save the file attachment to your home directory and open a Konsole window. The command to open a zipped file archive is simply unzip :

 [jharris@localhost jharris]$ unzip nephew.zip
Archive:  nephew.zip
 extracting: nephew1.jpg
 extracting: nephew2.jpg
 extracting: nephew3.gif

As you can see, the unzip program extracted three files from the zip archive ...

Get Test Driving Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.