How do I unzip ZIP archives under Linux?

tutorial for unzipping ZIP archives under Linux

How do I decompress ZIP files under Linux? That's the question we'll answer in this tutorial.

The ZIP format is commonly used to compress files and folders, facilitating data storage and transfer. By compressing data, weight is reduced, making data transfers faster.

Although many other options exist under Linux, including the TAR format, it has to be said that the ZIP format remains one of the most popular. As a system administrator, it's essential to know how to use it.

1. Installing the unzip package

Before you can unzip a ZIP file under Linuxyou need to ensure that your system has the necessary tools, i.e. the unzip. If it is not yet installed on your system, you can add it using the following commands :

sudo apt-get update
sudo apt-get install unzip

These commands update your package list and install the unzip package. Once installation is complete, you'll be ready to unzip ZIP files. To create ZIP archives, use the zip to be installed.

2. Getting started with the unzip command

How to order unzip is the main tool for decompressing ZIP files under Linux. Suppose you have downloaded a ZIP archive named " Project.zip" . To decompress this archive in the current directory, simply run the following command :

unzip Project.zip

This command extracts the contents of the ZIP archive into the current directory, which is very useful for quick access to compressed files. Before decompressing, it may be useful to check the contents of the archive, as we'll see in the next section.

3. Checking the contents of a ZIP archive

It can be a good idea to take a look at the contents of a ZIP archive before unpacking it, especially if you don't know exactly what it contains. It's as if it were a folder that we're going to open to find out more about its contents before manipulating it.

To do this, you can use the -l command. unzip :

unzip -l Project.zip

This command displays a detailed list of the files contained in the archive, including their size, modification date and name. This allows you to decide whether or not to extract specific files.

4. Uncompress an archive in a specific directory

In some cases, you may wish to extract the contents of a ZIP archive to a directory other than the current one. To do this, the -d is very useful.

For example, to decompress the archive named Project.zip in the /home/tutomakeryou would use the following command:

unzip Projet.zip -d /home/tutomaker

This command extracts the entire contents of the ZIP archive into the specified directory. You're then free to do what you like with the data.

5. Unzip a password-protected ZIP archive

ZIP files can sometimes be password-protected for security reasons, especially when they contain sensitive data.

To decompress such an archive, simply run unzip without any additional options. The tool will then ask you to enter the password corresponding to this archive. However, there is an option for specifying the password directly in the console: the -P.

Here's an example with the password "TutoM@ker".

unzip -P TutoM@ker Project.zip

This method allows you to decompress the archive... Provided you know the password, of course.

6. Extract a specific file from a ZIP archive

It's sometimes necessary to extract just one particular file from a ZIP archive, without having to decompress the whole thing. To do this, simply specify the name of the file to be extracted in the command unzip !

For example, here's how to extract the " Planning.xlsx "present in the ZIP archive Project.zip " :

unzip Project.zip Planning.xlsx

This command extracts only the specified file from the ZIP archive. This is very useful if the ZIP archive is large, but you're only interested in this one file.

7. Conclusion

After reading this article from the Computer Tutorials box, you are now able to decompress ZIP files under Linux using the command unzip.

These different options will enable you to use unzip according to your needs. In addition, please read the "man page" documentation for this command.

Related topics

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *