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.
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.
Syntax
zip's syntax is:
zip file.zip file1 file2 zip file.zip dir1 zip -option file.zip dir1
To zip directory called pics in your home directory (/home/you/pics), type the following command:
$ zip -r myvacationpics.zip /home/you/pics/
or
$ zip -r myvacationpics /home/you/pics/
The -r option recurse into directories (all files and directories inside pics) to produced zip file called myvacationpics.zip. 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 mycode.zip.
zip -R mycode.zip "*.c"
Please note that *.c will match file.c, dir1/file.c and dir1/dir2/.c and so on.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 18 comments… read them below or add one }
I forgot how to do this. First result on google, exactly what I needed. Thanks.
Same for me, very useful! Also simple things can be forgotten. Thank you!
Thanks….This is what i was looking for.
It helped me as well thanks :)
It’s good to be reminded!
Thank You!
Thanks! It helped bunches!
Thanks a ton.
man zip ?
thanks !
lol just do right click compress
I need to zip something on a linux server WITH NO GUI, and so this tutorial was very helpful. Thanks
what a smart ass.. this is a server we are talking about without a GUI
thanks.. can`t understand zip –help.. lol..
Very useful
Thank you
Great. Thx for help. Just what I need!
hay it is nice tutorial. But i want to know how should i un-zip the file
Wonderful. Saved my time.
Hi,
Is there a command line to set the zip compression ? As a lot of archiver do ?
Thanks !