QUICK TIP - Zip and Unzip on Linux with 2 easy WordPress Examples
- 1. QUICK TIP - How to make a YouTube subscription link and get more subscribers
- 2. QUICK TIP - Create Password Protected PDF with PHP & MySQL
- 3. QUICK TIP - How to make a YouTube subscription link and get more subscribers
- 4. QUICK TIP - How to add ads Startapp in the game Unity
Zip and Unzip on Linux – A Zip archive is a compressed file format that supports lossless data compression. A zip archive might contain multiple files and directories inside it. Zip is a very popular archive file format.
Almost every operating system supports zip including all the operating systems by Microsoft as well as all the Linux operating systems.
In this in-depth guide, I will show you how to install zip and unzip on Linux operating systems. We will also learn how to zip and unzip files in Linux.
In order to use Zip and Unzip in Linux, we have to first install Zip and Unzip on Linux operating system. Before we move on to the installation part, make sure you have sudo privilege on your Linux server.
We need sudo privilege to install new software packages on our server. So, If you have sudo privilege, you can continue with the tutorial.
Install Zip and Unzip on Linux(Ubuntu/Debian)
It is very easy to install these utilities on Ubuntu and Debian. Both these operating systems use
apt to manage software on the machine.
Execute the following commands to install zip and unzip utilities on Ubuntu/Debian operating systems.
$ sudo apt-get update
$ sudo apt-get install zip unzip -y
It will just take 10-20 seconds to install these utilities. Once the process is complete, execute the
zip command to verify the installation. You will get list of options and the version of zip as an output.
Install Zip and Unzip on Linux (CentOS)
The “Zip and Unzip on Linux” method will also work for Fedora operating system as both of them use
yum to manage software on the machine.
Execute the following commands on your server to install Zip and Unzip on CentOS server.
$ sudo yum update
$ sudo yum install zip unzip
Once the process is complete, execute the
zip command to verify the installation. Once the installation is done, we can move on to learn how to Zip and Unzip on Linux operating systems.
How to Zip on Linux
Zip is a very simple and straightforward utility. Let us first see the syntax of zip command.
$ zip [OPTIONS...] ZIP_FILE_NAME [FILES ...]
Options in zip command allows us to control the execution of the command. Then comes the ZIP_FILE_NAME, we have to replace this with the name of the zip file we want to create, for example,
Then, you can list all the files that you want to include in this zip archive.
COMPRESS INDIVIDUAL FILES
For example, Let’s say we have file1.txt and file2.csv that we want to zip. To compress these files inside a zip archive, we have to run the following command.
$ zip files.zip file1.txt file2.csv
This command will create a zip archive called
files.zip in the current directory.
COMPRESS A DIRECTORY
Now, Let’s say we have a directory called
wordpress that we want to compress in a zip archive. To create a zip archive of a directory, we will use the
-r option in zip command.
-r option will make the process recursive, it means that the zip archive will contain every file and subdirectories contained inside the directory we want to compress.