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 .zip
files, so we need to install one first. Let’s get started.
Contents
- Recommended Books
- Install unzip on Ubuntu/Debian
- Install unzip on Fedora/CentOS
- How to unzip a file
- Conclusion
- See Also
- Further Reading
Recommended Books
I can highly recommend these books on Linux Administration if you want to go further.
- The Linux Bible 10th Edition
- The Linux Command Line, 2nd Edition: A Complete Introduction
- Linux Administration: The Linux Operating System and Command Line Guide for Linux Administrators
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 myzipfile.zip
Unzip Options (switches)
There are many options/switches you can use with unzip. Here are a few of the most useful.
-d Switch
The -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
command.
sudo unzip myzipfile.zip -d /var/www
-P Switch
If the zip archive is password protected, use the -P
switch.
unzip -P MyPassword myzipfile.zip
-o Switch
If you need to overwrite existing files and do not wish to be prompted, use the -o
switch.
unzip -o myzipfile.zip
-n Switch
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
If you want to see more switches, arguments and options for unzip, see the Linux unzip man page.
Comments
There are currently no comments on this article.
Comment