In this guide, you’ll learn to unzip files in almost any Linux distribution, and it’s a lot easier than you think. Most Linux distributions don’t have an app for unzipping files, so we need to install one first. Let’s get started.
Install unzip on Ubuntu/Debian
Open your Terminal application, then enter the following code:
sudo apt install unzip
Install unzip on Fedora/CentOS
Open your Terminal application and enter the following code:
sudo yum install unzip
How to unzip a file
To unzip a file to the current directory (the same directory the zip file is in) use the following command in Terminal:
Unzip Options (switches)
There are many options/switches you can use with unzip. Here are a few of the most useful.
-d switch gives you the option of extracting the zip archive to a different folder than the current one.
unzip myzipfile.zip -d /path/to/directory
If you’re unzipping to a directory that you don’t have permissions for, use the
sudo unzip myzipfile.zip -d /var/www
If the zip archive is password protected, use the
unzip -P MyPassword myzipfile.zip
If you need to overwrite existing files and do not wish to be prompted, use the
unzip -o myzipfile.zip
If you’ve already unzipped a file and made some changes, and for some reason need to unzip the file again (maybe you deleted some files), you can use the
-n switch which will skip any existing files.
unzip -n myzipfile.zip
Conclusion & Further Reading
If you want to see more switches, arguments and options for unzip, see the Linux unzip man page.