

Here is an example to compress all files in /home/data folder $ sudo zip -q myfiles.zip /home/data/* If you want to compress all files in directory and not the directory itself, you need to use wildcard patterns as shown below. $ sudo zip -r myfiles.zip /home/data /home/project If you don’t want to view the compression progress, use -q option for quiet mode. The above command will show the compression percent for each file and can be quite big depending on your folder contents. $ sudo zip -r myfiles.zip /home/data /home/projectĪdding : /home/data/file1.txt (stored 0%)Īdding : /home/data/file2.txt (deflated 10%)Īdding : /home/project/file3.txt (deflated 20%) Let us say you want to compress folders /home/data and /home/project then here is the command to do it.

If you want to compress all files in directory, you need to mention -r option for recursive compression. zip extension to your zip file, it will automatically add it. It displays the compression percent for each file. $ sudo zip myfiles.zip file1.txt file2.txt file3.txt

Let us say you have to compress 3 files file1.txt, file2.txt and file3.txt in your present working directory, just run the following command to zip them. Now we will look at a few common use cases for your reference. Otherwise use sudo keyword before zip command above. It is important that you have the permission to create zip file in the target directory. If you want to create zip file in another directory, specify full path to zip file. If you only mention zip_file_name then the zip file will be created in your present working directory. In the above command you need to mention the name of your zip archive after zip command, followed by a space-separated list of file names. Here is the syntax to zip one or more files & folders $ zip zip_file_name file(s) Open terminal and run the following command to install zip utility. Here are the steps to zip files & folders in Linux. In this article, we will look at how to zip files & folders in Linux. It allows you to easily compress files & folders to transfer or store. Zip is a lossless compression tool supported by all Linux systems. It also supports zip compression utility, which is commonly used in Windows. Linux offers many compression tools like gzip and tar for this purpose. Often you will need to compress files & folders before sending them to others, or for the purpose of archival.
