Compress or ZIP a Folder Using Linux zip Command: A Beginner Guide – Linux Tutorial

By | July 27, 2022

We often need to compress a folder or directory to a .zip file. In linux, we can use zip command to implement. In this tutorial, we will use some examples to show you how to do.

Compress some files

We do not  need to compress a file. If we want to compress some files to a .zip file, we can use command below:

zip archivename.zip filename1 filename2 filename3

For example:

zip test.zip 1.wav 2.wav

We will compress 1.wav and 2.wav to test.zip file.

Compress a folder

It is easy to compress a folder, we can use this command:

zip -r archivename.zip directory_name

For example:

zip -r test.zip wavs

We will compress wavs directory to test.zip

Compress or ZIP a Folder Using Linux zip Command: A Beginner Guide - Linux Tutorial

If you do not want any output, you can add -q argument.

For example:

zip -qr test.zip wavs

Compress some folders

We also can compress some folders using zip command. Here is the example:

zip -r archivename.zip directory_name1 directory_name2

Compress some folders and files

We also can compress some files and folders at the same time.

For example:

zip -r archivename.zip directory_name1 directory_name2 file1 file1

Leave a Reply