Zipping and Unzipping Files under Linux

Posted on in Categories File system, Linux desktop, Linux distribution last updated December 14, 2005

Asked by Yamir via e-mail

Question: MS-Windows has winzip program. I cannot find anything under Application menu to zip or unzip files on Linux. I am using Debian Linux. How do I zip and unzip file under Linux operating systems?

Answer: Linux has both zip and unzip program. By default, these utilities are not installed. You can install zip/unzip tools from the shell prompt. Open the Terminal by clicking on Application > System Tools > Terminal. You must be a root user, Type the following two commands to install zip and unzip program on Debian or Ubuntu Linux:

# apt-get install zip
# apt-get install unzip

OR
$ sudo apt-get install zip unzip
If you are Red Hat Linux/Fedora/CentOS Linux user then you can use the yum command to install zip and unzip program as follows:

# yum install zip
# yum install unzip
  • zip is a compression and file packaging utility for Linux and Unix (including FreeBSD, Solaris etc).
  • unzip will list, test, or extract files from a ZIP archive files.

ziping files/directories examples

Creates the archive data.zip and puts all the files in the current directory in it in compressed form, type:

$ zip data *

Note: No need to add .zip extension or suffix as it is added automatically by zip command.
Use the ls command to verify new zip file:
$ ls
To zip up an entire directory (including all subdirectories), type the following command:

$  zip -r data *

unziping files/directories examples

To use unzip to extract all files of the archive pics.zip into the current directory & subdirectories:

$ unzip  pics.zip

You can also test pics.zip, printing only a summary message indicating whether the archive is OK or not:

$ unzip -tq pics.zip

To extract the file called cv.doc from pics.zip:

$ unzip pics.zip  cv.doc

To extract all files into the /tmp directory:

$ unzip pics.zip  -d /tmp

To list all files from pics.zip:

$ unzip -l pics.zip

Linux GUI packages

You can use the following graphics packages

(1) KDE Desktop: Ark is an Archive Manager for the KDE Desktop. You can start Ark from Application > Accessories.

(2)GNOME Desktop: File Roller ia an Archive Manager for the GNOME Desktop.

See also

For more information please consult the following resources:

26 comment

  1. I have tried the command that specified, but here it won’t work(am using linux suse 8.2′ ), can you please clarify why it’s not working?

  2. Hi,
    Can someone tell me how to put the zip file in another directory? I tried -d but that didn’t work, I got the error: ‘zip error: Nothing to do!’

  3. This doesn’t seem to produce a file, it goes through deflating all the files, but no file is made… I can even grep the entire system and there will be no .zip fie of any sort.

  4. Garbage! Yeah, it creates *AN* archive, and *SOME* things might be able to read it, but its clearly not a valid, standard one, and some software won’t recognize the file or read it all. Thus, its basically outputing garbage. I need to save for a real operating system, one that actually runs useful softward.

  5. after installing zip { # apt-get install zip }
    to unzip a file in linux (ubuntu) just type :
    unzip foldername
    no need to add extension (zip)
    and thats it,

  6. This is an answer to almost every single problem with unzipping files under Linux. Ironically enough this involves using the program 7-zip for Windows. (Bear with me here, this is actually helpful for those who have issues with Linux unzipping programs)

    1. Install WINE (sudo apt-get install wine)

    2. Download and install the 7-zip exe version (download from 7-zip.org, double click it to install, WINE should run the installation program, just go through the prompts to finish install)

    3. Add the 7-zip icon to the panel beside the task bar (It is located in Start menu > WINE > Programs > 7-Zip), there is a way to do this for most desktops.

    4. Click and drag the archive you want to extract onto the icon beside the task bar. It will open the program 7-zip and from there all you have to do is click on Extract and pick a directory (the file’s current directory is default)

  7. NOTE: I posted this idea as an alternative for when all else fails, I am not in any way endorsing use of this program for any other reason.

  8. it’s like many people facing issue archiving their files on linux .
    in shor zip and unzip command not provided with linux distrbutions by dfualt .
    so we need to use tar command instead .:-
    BTW tar defualt stting not zipping file but put it on one uncompressed file with .tar extention .
    to compress with tar
    tar -czf ~/backup-archive.tar.gz ~/backup/
    ~/backup/ is the targit directory
    to uncompress on current directory
    tar – ~/backup-archive.tar.gz
    To uncmpress to specified directory
    tar -xzvf ~/backup-archive.tar.gz -C /target/directory

    This is best way compress uncompress on linux command line .

Leave a Comment