Zipping A Directory In Linux Terminal

by on October 31, 2007 · 21 comments· LAST UPDATED September 12, 2012

in , ,

How do I zip files in Linux so that I cam email them to my friend? How do I zip files on server using the shell prompt?

zip is a compression and file packaging utility for Unix, Linux, VMS, MSDOS, OS/2, Windows NT, Minix, Atari and Macintosh, Amiga and Acorn RISC and many other operating systems.

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementszip utility
Estimated completion timeN/A

This utility is installed by default on most Linux computers and servers. The program is useful for packaging a set of files for distribution; for archiving files; and for saving disk space by temporarily compressing unused files or directories.


zip's syntax is:

zip file1 file2
zip dir1
zip -option dir1

To zip directory called pics in your home directory (/home/you/pics), type the following command:
$ zip -r /home/you/pics/
$ zip -r myvacationpics /home/you/pics/
The -r option recurse into directories (all files and directories inside pics) to produced zip file called You can travel the directory structure recursively starting at the current directory. In this example, all the files matching *.c in the tree starting at the current directory are stored into a zip archive named

zip -R "*.c"

Please note that *.c will match file.c, dir1/file.c and dir1/dir2/.c and so on.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 21 comments… read them below or add one }

1 bryan January 9, 2009 at 2:01 am

I forgot how to do this. First result on google, exactly what I needed. Thanks.


2 Luuk January 16, 2009 at 10:46 am

Same for me, very useful! Also simple things can be forgotten. Thank you!


3 Dhawal June 10, 2009 at 8:22 am

Thanks….This is what i was looking for.


4 Vishwajeet Singh February 13, 2010 at 7:46 am

It helped me as well thanks :)


5 Bojan Sukalo May 6, 2010 at 9:58 am

It’s good to be reminded!

Thank You!


6 VinceHardsmash September 17, 2010 at 6:52 pm

Thanks! It helped bunches!


7 Sunil January 28, 2011 at 3:58 am

Thanks a ton.


8 zippa March 14, 2011 at 10:33 am

man zip ?


9 sushil April 28, 2011 at 12:27 pm

thanks !


10 bob June 20, 2011 at 4:08 pm

lol just do right click compress


11 JJJollyjim July 28, 2011 at 11:33 pm

I need to zip something on a linux server WITH NO GUI, and so this tutorial was very helpful. Thanks


12 smart September 12, 2012 at 4:58 pm

what a smart ass.. this is a server we are talking about without a GUI


13 Ahmad Fikrizaman January 23, 2012 at 7:12 pm

thanks.. can`t understand zip –help.. lol..


14 Ahmed Adel February 29, 2012 at 12:18 am

Very useful
Thank you


15 hoze April 6, 2012 at 11:29 am

Great. Thx for help. Just what I need!


16 Sam October 13, 2012 at 4:13 am

hay it is nice tutorial. But i want to know how should i un-zip the file


17 Sukumar October 17, 2012 at 10:24 am

Wonderful. Saved my time.


18 joneskind January 14, 2013 at 1:19 am


Is there a command line to set the zip compression ? As a lot of archiver do ?
Thanks !


19 prafulla July 11, 2013 at 8:02 am

Thanks a lot it worked for me as well, while its bit time consumming..
any other way to process it bit faster???


20 yash August 16, 2014 at 7:33 am

thanks! It helped!


21 Abdul Basit Nawab April 14, 2015 at 1:09 pm

Yeah! work like a charm.


Leave a Comment

Tagged as: , , , , , ,

Previous Faq:

Next Faq: