A passionate programmer’s findings in the world of internet.

Zip a Folder in Linux

May 31st, 2007

I keep forgetting the command to zip a folder in Linux (Red Hat Enterprise Linux 4). And I have even got all files in the folder got zipped individually when I typed the command wrongly, which looked funny to me. The correct command, to remind myself:

zip -9 -r <zip file> <folder name>

To zip a single file:

zip -9 <zip file> <filename>

Use "-9" for best compression. The compressed file works fine with Windows XP compression tool.

If my article helped you solved your problem, consider buy me a beer!

Share this article: del.icio.us | digg it


Related posts:

16 Responses

Anurag Bhandari says:

If logged into KDE, I prefer right-clicking on the folder to be compressed and selecting Compress > Compress as > folder.zip.
Isn’t that simple..?

EngLee says:

That’s simple enough, but I’m working on a linux server through telnet, instead of UI.

R.ManjuParkavi says:

Dear sir,

For zip a folder i got idea from your site by searching google.co.in website. But using that
zip -9 -r it is not working in my shell. i dont know y it is not working.

while doing this command it say’s “nothing to do ” wat is it means then wat i have to do next.

Please guide me.

Waiting for your reply………….



EngLee says:


In my attempt to simulate your problem I performed the following command.

zip -9 -r playground.zip

And I get the following error:

zip error: Nothing to do! (playground.zip)

If that’s the case, I think you forgot to specify the target folder. You need to enter the following command (assuming I have a ‘playground’ folder):

zip -9 -r playground.zip playground

hai says:

very simple and seem work fine, thanks for your tips :)

Shameer says:

I have executed the command specified above. Both r working fine

SUKET says:

Thanx Dear,

IT WORKS , and solved my major problem……

Thanx alot

DexterV says:

Thanks, that worked on a Suse 10 box that was mistakenly installed with no GUI by a I-want-to-control-everything-tourist-consultant-know-it-all that was hired (mistakenly) for a couple of months by our company.

John says:

Thanks a lot you just saved my ass I couldn’t remember it for the life of me!

happylife says:


Thank you for sharing. It did help me lots…

anshul says:


you have blog and i learn a lot from your blog. thanks BUDDY

Ash says:

Do i need to have root access to use this command? I tried it and it said 0% stored and i did this under my regular username. I would try root but they don’t want to give me root password which is lame.

Sebastian says:

Thanks! I forgot that specific command order:
zip -r output input
instead of so common input output… :d

Mohammed says:

Thanks Mr. EngLee

that was easy enough.


Ifeanyi Aneke says:

Thanks for the post. It really was useful. Thanks once more.

Naz Hasan Huda says:

Thanks a lot for sharing this. Worked like a charm. Simple command does the job pretty well. And best feature is that the produced zip file is usable in both windows & linux. You are THE MAN… :)