In this Linux commands article, you will learn how to use zip/unzip command-line utilities to create and extract zip file files on Linux/Unix-like operating systems.

There are times when you only have to rely on the command-line and you come across a situation where you have to create or extract a zip file. Luckily, we have zip/unzip utility-tools that helps us to archive this task.

In this quick guide, you will go through the usage of zip/unzip commands and learn how to install them on Linux. So let’s get started.

Installing zip/unzip command-line utilities

You can easily install zip/unzip command-line utilities on Linux as both are available in the official repositories of your distribution. So just use your package manager to get them.

On Debian/Ubuntu and their derivatives.

sudo apt install zip unzip -y

For Redhat family – Fedora, CentOS, etc.

sudo dnf install zip unzip

Learn more about apt: Complete apt package manager guide for Linux

Creating zip file using command-line

You can use the zip command to create .zip archive file. Here is an example.

Command structure:

zip archiveName.zip file1 file2 file3
or
zip -r archiveName.zip folderName

zip command usage

To create a zip archive of an entire folder. (-r parameter is to tell the command to recursively add all the files/folders in side this folder)

creating a zip archive of a folder

For more information about the different parameters and options, checkout the help page for zip commnad.

zip -h

Extracting a zip file using the command-line

In order to extract a zip file in the same directory, use the unzip command.

unzip archiveFile.zip

If you want to extract the file content in a specific folder then use the -d flag to and specify the location.

extracting zip archive file with unzip

In the above example, ezip folder name is specified. You can use any particular location you want and for more usage options, go through the help page.

unzip -h

Watch Video guide on YouTube

Additionally, You can also watch a step-by-step video guide on YouTube to get a better understanding of it.

Conclusion

So that’s it on how to create and extract zip archive files using the command-line. Let me know what you think about it in the comments and subscribe to the LinuxH2O Youtube channel. Till then, keep enjoying Linux.