VPS House Ad
Home Articles How to zip the directory in linux with command line

How to zip the directory in linux with command line

Dashlane Ad

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.

The below command will help to find is zip installed or not.

# which zip (It will show the absolute path of zip)

In CentOS

Dashlane Ad

# 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

WHMCS Ad