How To Unzip Files On Linux Operating System
This tutorial is basically intended for the beginner level of Linux users. In this Linux command tutorial post, you will get the answers to the following questions:
- How To Unzip Files On Linux
- How To Unzip Files From Terminal On Linux
- Zipping And Unzipping Files In Linux
- How To Compress. And Extract Files On Linux
- How to unzip a file in Ubuntu and other Linux distributions
Linux How To Unzip Files Tutorial For Everyone
At first, we need to install Unzip in the Linux operating system. Most of the Linux based operating systems included these Zip utilities in the standard installation. But if you don’t have run the following commands to install Unzip files in your suitable Linux operating systems:
Install Unzip on Ubuntu and Debian based operating systems:
sudo apt install unzip
Install Unzip On CentOS/RHEL/Fedora:
sudo yum install unzip
How to Unzip A ZIP file In Linux Operating System
This is the process of extracting all the files from the specified ZIP archive to the current directory.
Suppose you have a file sample.zip. You must have a write permissions on the directory where you are extracting the ZIP file. To unzip this file to the current directory, you’d simply run the following command in your terminal.
unzip sample.zip
Run the following command to unzip a ZIP file to a different directory than the current one. You can use the -d
switch with regular command along with the path to the directory where you want to extract:
unzip filename.zip -d /path/to/directory
Example:
sudo unzip sample.zip -d /var/www/file
Run the following command to see the contents of the file without extracting. We will use -l option:
unzip -l sample.zip
Run the following command to extract the password-protected file:
unzip -P Password passwordprotectedfile.zip
In another method, you can simply run the following command to extract the password-protected file and the unzip will ask you the password instantly. Unzip will prompt you to enter the password:
unzip passswordprotectedfile.zip
Run the following command to extract the file without overwriting the already extracted file:
unzip -n filename.zip
Run the following command to unzip multiple zip files in the current directory:
unzip '*.zip'
How To Zip Files And Directories In Linux
If you don’t have zip tool installed in your Linux, run the following command:
For Ubuntu:
sudo apt install zip
For RedHat/CentOS/Fedora:
sudo yum install zip
Run the following command to compress the file in Linux:
zip archivename.zip file_name
Run the following command to compress the multiple files at once in Linux:
zip archivename.zip file_name1 file_name2 file_name3