When downloading files from the Internet, it’s common to receive them in an archive format, such as .zip. Archives serve various purposes, including reducing download sizes, organizing multiple files into a single package, providing basic integrity checks, and sometimes adding security with passwords. On Windows, GUI archiver tools like WinZip, 7zip, or WinRAR make it easy to handle different archive types. Ubuntu Linux, on the other hand, offers a built-in Archive Manager for handling these archives in a graphical user interface (GUI).
However, what do you do if you’re working on Ubuntu Linux and need to unzip a .zip file from the command line? This situation might arise when you’re using Ubuntu Server or a terminal-based environment. In this guide, we’ll show you how to unzip .zip files on Ubuntu Linux using the terminal.
Installing the unzip Package
Before you can extract .zip files from the terminal, you need to ensure you have the ‘unzip’ package installed. To do this, follow these steps:
- Open a terminal by searching for “Terminal” in your applications or pressing Ctrl+Alt+T.
- To install the ‘unzip’ package, use the following command:
12345sudo apt-get install unzip
You may be prompted to enter your admin password and confirm the installation by typing ‘yes.’ Allow the package manager (apt) to allocate additional disk space as required.
Extracting .zip Files
Now that you have ‘unzip’ installed, you can extract .zip files using the following command:
1 2 3 4 5 |
unzip archive.zip |
This command will extract the contents of the ‘archive.zip’ file, which should be located in your current directory, and it will extract the contents to the same directory.
If you wish to extract the .zip file to a different directory, you can use the ‘-d’ option followed by the destination folder path. Here’s how:
1 2 3 4 5 |
unzip file.zip -d destination_folder |
For example:
1 2 3 4 5 |
unzip mysite.zip -d /var/www |
This command will extract the contents of ‘mysite.zip’ to the ‘/var/www’ directory. You can specify either a full or relative directory path.
Conclusion
Unzipping .zip files on Ubuntu Linux via the terminal is a straightforward process. With the ‘unzip’ package installed, you can quickly extract the contents of your .zip archives. Whether you’re working in a terminal-only environment or prefer command-line operations, Ubuntu Linux provides you with the tools necessary to manage these archive files efficiently.