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 | |
---|---|
Difficulty | Easy (rss) |
Root privileges | No |
Requirements | zip utility |
Time | N/A |
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.
🐧 27 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
I forgot how to do this. First result on google, exactly what I needed. Thanks.
I forgot it as well, although my search engine wasn’t google. It was duckduckgo, but still the first result though. :’)
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 !
Hi,
Thanks a lot it worked for me as well, while its bit time consumming..
any other way to process it bit faster???
Yes, you can add “-0” to not compress files, but only store.
You can use -0, -1, -2, -3.. etc up to -9
( -9 nine compress better, -0 compress faster )
thanks! It helped!
Yeah! work like a charm.
This is greeeeeeeeeeeeat!!! Thanks a loooooooooooooooooot!!! :D
thank you!!! :)
Thanks a lot!
A Quick Tip… But Really Very Helpful.
Thanks Buddy! :)