Packing a few documents and envelopes into a solitary distributable single file is the most well-known process done by numerous PC clients around the globe. In Windows, you can just utilize Winzip, WinRAR, 7Zip, etc to compressing and extracting documents.
Compressing records is a simple, proficient approach to move files among PCs and servers. At the point when files are compacted, they not just spare more space on a local HDD or SSD drive yet additionally make it simpler and progressively advantageous to download compressed documents from the web, utilizing far less data transmission than sending full-size data.
However, in the Linux server, there is no graphical interface to zip and UnZip files. So the question is – How to ZIP UNZIP Files in Linux Server? Here we are going to discuss that.
1. Log into server
Login to your Linux (Ubuntu, Debian, CentOS, Fedora, etc.) using SSH client PuTTy or whatever you like.
2. Install UNZIP utility on the server
To compress and extract files and folders it is necessary to install a small program called UNZIP. Here you go.
# For Ubuntu and Debian server
sudo apt install unzip
# For CentOS and Fedora Server
sudo yum install unzip
3. How To use UNZIP command
To unzip a compressed .zip file, first, navigate that folder where the .zip file is located. To do that you can use the
cd command. For my case .zip file is located at
/home /som /folder/. So that I will use the command-
Next, the command
ls helps to see all the files inside the folder. Now to see the possible arguments of the command
unzip type the following –
Thus the general command to unzip a single file is –
In my case, I would like to unzip
wordpress.zip file, so I use
Here is a screenshot for the output
4. Extract multiple files
The unzip command also allows us to extract or decompress multiple files simultaneously. For that, you need to
'*.zip' files followed by
5. How to exclude some zip files?
-x switch followed by the command
unzip, allows you to exclude unzipping your desired file. Suppose I have
mypic.jpeg inside the
myallimg.zip file and I want to extract all escept
mypic.jpeg. Then the command should look like –
unzip myallimg.zip -x mypic.jpeg
6. How do I extract a ZIP File to another folder?
-d switch will do the whole job. If I want to extract filename to /home /user /admin folder then my command would be –
unzip filename.zop -d /home/user/admin/
7. How to see the contents inside a zip file?
The -l switch allows showing all the files stored inside a zip file. For that use the following command.
unzip -l yourfile.zip
8. How to get detail info of a zip file?
To the detail information of a compressed zip file, I will use -v switch followed by the command unzip. For example, I want to see the information about the
unzip -v abc.zip
9. How to unzip password protected zip file?
Some time for security purpose we set a password to a zip file. So to extract a password-protected file we use the following command.
unzip -P your_password yourfile.zip
10. Compress (ZIP) all files in the same directory
If we want to compress some files into a single zip file, then the command
zip will easily allow us to do so. The general command for that is –
zip [your_file_name] file1 file2 file3
Suppose we want to compress two files
readme.html inside file
abc, then the command should be –
zip abc license.txt readme.html
To zip all the files is the same folder we use the following command.
zip abc *
abc is the output zip file.
11. Check the validity of a ZIP file
Whether a zip file is corrupted or not, we can easily check out using the command given below. Here,
-tq switch allows us to check that file.
unzip -tq ppp.zip
I believe that that’s enough to know about compress and extract for unzipped and zip files respectively to work in a Linux server. If any important command missed out then leave a comment bellow.