To prevent various sorts of theft or destruction, practically all files, including documents and media assets, are transferred in the zip format.
Additionally, a password can be specified to prevent unauthorized access to the files, preserving the privacy of the contents.
Even still, working with these kinds of files presents several challenges for novice users, those who lack sufficient computer literacy, and those without an IT background, such as opening zip files and compressing information, among other things.
To help you better understand the compression process, it’s also important to learn how to zip files in Linux. For a comprehensive guide on creating zip files, check out our detailed tutorial on how to zip a file in Linux.
Prerequisite of unzipping files in Linux
You need the unzip package installed on your computer to open a zip archive file. Most current Linux distributions already support unzip, but it doesn't hurt to double-check now to avoid unpleasant surprises later.
Use this command in a terminal:
unzip --version
If it provides more information, you already have to unzip the installed. If you see a notice saying "unzip command not found", you must install it.
Use the following command to install unzip in Ubuntu and Debian-based distributions.
sudo apt install unzip
Once you have confirmed that your system supports unzip, you can unzip files in Linux.
You can also move the unzipped files to a different directory using the mv
command. For more details on how to move files in Linux, check out our guide on how to move files in Linux.
Unzip files in Linux using the command line
The unzip command is quite easy to use. Use the following command in the directory where the zip file is located:
unzip zipped_file.zip
Instead of navigating to the directory, you can also specify the path of the zip file. In the output, you'll find extracted files:
unzip metallic-container.zip -d my_zip
Archive: metallic-container.zip
inflating: my_zip/625993-PNZP34-678.jpg
inflating: my_zip/License free.txt
inflating: my_zip/License premium.txt
This command appears to be extremely practical overall. If the user uses the command above carelessly, he may occasionally get into a bigger issue.
This command's main drawback is that it frequently extracts the whole contents of the selected zip file into the current directory or folder, which is undesirable, at least in some circumstances.
To avoid cluttering your directory with unwanted files, you may want to use the find
command in Linux to locate specific files within the extracted contents. You can learn more about using the find
command effectively in our guide on how to find files in Linux.
Unzip to a specific directory
The issue above can be easily avoided by unzipping the target file to a separate directory rather than extracting it into the current directory.
In this manner, the directory chosen will house all of our extracted files. It will also take care of it by establishing the directory with the provided label if the user-specified directory is not there in some cases.
The steps below can be used to unzip a zipped file to a specific folder or directory:
- From the terminal, go to the directory where the compressed or zipped file is located.
- When you've arrived at that directory, enter this command into the terminal: unzip zipped_file.zip -d unzipped_directory
- The zipped file’s whole contents will now be extracted to the unzipped directory.
Unzip files in Linux via GUI
If you use desktop Linux, visiting the terminal is not always necessary. Users of this strategy, especially beginners, will find it incredibly straightforward.
It simply appears like the window's zip file extraction process. Follow the guidelines below for unzipping files in Linux using the graphical user interface.
First, go to the folder containing your zip file using the file manager. The option "extract here" will appear when you right-click the file. Choose it.
The "extract here" option, in contrast to the, unzip command, create a folder with the same name as the zipped file and extract all of the contents of the compressed files into this newly created folder.
You can also select the folder to which you would like to extract the files by choosing the "extract to" option.
Unzip files in Linux using Archive Manager
Many Linux distributions include Archive Manager as a default installation, providing a quick and simple way to unzip files in Linux.
First, navigate to the zip file's directory by opening the Files app. Then, select the "Open With Archive Manager" option by right-clicking the file.
The zip file's contents will be opened by Archive Manager and seen there.
To extract the contents into the current directory, select "Extract" from the menu bar.
Unzip a password-protected ZIP file.
Run the unzip command with the -P option and the password to unlock a password-protected file:
unzip -P PasswOrd filename.zip
Password input on the command line is unsafe and ought to be avoided. Extracting the file normally without entering the password is a more secure alternative.
If the ZIP file is protected with encryption, will request the password:
unzip filename.zip
Exclude a file when unzipping files in LinuxBasic Linux Commands
Use the -x option and a list of archive files you want to stop extracting, separated by spaces, as follows to prevent particular files or directories from being extracted:
unzip filename.zip -x file1-to-exclude file2-to-exclude
Conclusion
One of the most typical and well-liked methods for producing compressed archive files is Zip. It was developed in 1989, making it one of the older archive file formats. You'll frequently encounter a zip file because it is so commonly used.
By following one of the mentioned methods, you will have no problem unzipping files in Linux. We offer that you buy linux vps server and you practice.
Additionally, if you're looking to explore more about working with files in Linux, check out our guide on how to create files in Linux to expand your knowledge and enhance your Linux skills.
People also read: