Zipping and Unzipping Files under Linux

by on December 14, 2005 · 15 comments· LAST UPDATED July 10, 2007

in , ,

Asked by Yamir

Q. Windows has winzip program what about Linux; I cannot find anything under Application menu. I am using Debian Linux distribution. How do I zip and unzip file under Linux?

A. Linux has both zip and unzip program. By default, these utilities not installed (see Linux winzip like GUI tools/utilities below). To install them from shell prompt (open shell prompt by clicking on Application > System Tools > Terminal ). You must be a root user, Type following two commands to install zip and unzip program:

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

If you are Red Hat Linux/Fedora user then you can use yum command to install zip and unzip program:

# 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.

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

$ zip data *

No need to add .zip extension or suffix as it is added automatically by zip command.

To zip up an entire directory (including all subdirectories), the command:

$  zip -r data *

unzip example:
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 like Winzip:
You can use graphics packages

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

* GNOME Desktop: File Roller ia an Archive Manager for the GNOME Desktop.

For more information please consult following resources:



If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+, or even by subscribing to our RSS Feed.


{ 15 comments… read them below or add one }

1 anol September 5, 2006 at 5:58 pm

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?

Reply

2 nixcraft September 5, 2006 at 8:48 pm

You must install zip and unzip commands. Use yast or rpm command to install these programs.

Reply

3 michel March 25, 2008 at 6:39 pm

thank man very useful for a non-developer type of guy like me.

Michel

Reply

4 Angel February 27, 2009 at 2:25 pm

I dont understand how you add it all
if someone is kind enough to take some time and walk me threw it please add me to msn
its crazycat_69@hotmail.com

Thx angel

P.S i am not very computer smart
and i am really disllinking ubuntu
because i cant get thing working on it

Reply

5 Amir zaman December 9, 2009 at 10:31 am

salam!
I have installed linux red hat 5 and i want to zip my folder containing pictures.
thanks.
Regards
Amir zaman.

Reply

6 Greg K September 1, 2010 at 12:29 am

I’d like to zip into parts, 499mb each from 1 ssh command

Reply

7 Satz April 28, 2011 at 5:27 am

hi i am new in linux. how to execute a zip file in linux…

Reply

8 Ganapathy S June 3, 2011 at 12:32 pm

how to extract rar file in redhat linux system please navigate me?

Reply

9 Aswin Karthickeyan March 5, 2012 at 11:53 am

tar -xvf /dir/etc.tar

Reply

10 sibaram June 6, 2011 at 3:14 pm

Hi….
I am new in ubuntu and want to install winzip software,
Plz kindly tell me what is the command to install winzip…

Reply

11 Shawn July 21, 2011 at 1:19 am

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!’

Reply

12 Shawn July 21, 2011 at 1:20 am

I need to do it in one line btw, so I can’t use cp or mv
I’m running it with a php script.
Thanks.

Reply

13 Srinidhi January 23, 2012 at 6:53 am

can any 1 help me

How to rename or replays a filefolder in odi O.S Linux redhat

Reply

14 steve January 24, 2012 at 4:37 pm

Shawn cp /directory /home/name/place you want
Ganapathy tar -zxvf filename.tar.gz

Reply

15 Roland June 9, 2012 at 4:49 pm

Thank you for this useful thread.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 6 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.

Tagged as: , , , , , ,

Previous post:

Next post: