In this tutorial we will learn,how to zip the directory in linux with command line.Zip is a compression and file packaging utility for Linux,Unix,Windows and various Operating system. The zip helps to compress and reduce the size of file and directory.To zip a directory,first of all we will check ,do we have zip command installed in Linux system.
Note: For more detailed zip examples with command line, read out this post (How to zip directory in linux explained with examples).
The below command will help to find is zip installed or not.
# which zip (It will show the absolute path of zip) In CentOS # rpm -q zip In Debian or Ubuntu $ sudo dpkg -l zip
If you find it is not installed in system then install with given below command.
In CentOS or Red hat # yum install zip In Debian or Ubuntu $ sudo apt-get install zip
After confirmation of installed zip package,now we will zip or compress the directory in Linux system.
Use the given below command.
zip -r GiveAnyName.zip /path/of/Directory for eg. We have a backup directory in /root/ (i.e /root/backup) zip -r backup.zip /root/backup
The command will compress the directory with extension .zip .
In above given eg. the compressed file name would be backup.zip
Thank you for shared this!
I needed that with my Centos 5.9.
Welcome Viktor,
I have updated the zip commands example in our new post.For further reading, her is the URL https://sharadchhetri.com/2013/10/18/how-to-zip-directory-in-linux-explained-with-examples/
Ok, I had not seen it, I’ll take a look.