How to unpack ZIP in Linux?

How to unpack ZIP in Linux?

In the WIndows operating system, the format of ZIP archives is almost standard, it is even supported at the level of this operating system. If you just switched from Windows, then you probably have a lot of such archives with different files, also ZIP archives can often come across on the Internet. Therefore, you definitely have to work with such files in Linux.
In this short article, we’ll look at how to unpack ZIP in Linux. Several methods and several utilities that will be able to cope with this task will be considered.

Unpacking ZIP Linux

Format zip was created in 1989 to replace the then very slow format arc. It uses deflate compression and at that time it worked much faster than arc. But historically, the standard format for Linux was TAR and GZ, these are advanced compression and archiving algorithms. Many graphic unpacking supports decompression including ZIP files. But they do not unpack the archives themselves, but give the command to utilities intended for this format.
The utility for unpacking zip is called unzip and is not always installed by default. But you can very easily install it from official repositories. To do this in Ubuntu:
 $ sudo apt install unzip
And in systems using the Red Hat package format, the command will look a little different:
 $ sudo yum install unzip zip
After the installation is complete, most graphical utilities for working with archives will be able to unpack the zip linux archive. The zip linux command is installed in case you want to create zip archives.
But this utility does not need additional shells for unpacking the archive. You can do it right from the console. Let’s look at the syntax of the utility:
$ unzip options files -x exclude -d folder
  • the archive file is the file with which we are to work;
  • files – here you can specify the files to be extracted, separate the file names with a space;
  • exclude – files that you do not need to extract;
  • folder – the folder to which the archive will be unpacked.
Now let’s look at the utility options, as it allows not only unpacking the archives, but also performing certain actions with them:
  • -l – list the files in the archive;
  • -t – test the archive file for errors;
  • -u – update existing files on the disk;
  • -z – output comment to the archive;
  • -c – extract files to standard output, before each file its name will be displayed;
  • -p – the same, only the name will not be displayed;
  • -f – extract only those files that already exist on the disk, and the files in the archive are newer;
  • -v – display all available information;
  • -P – specify the password to decrypt the archive;
  • -n – Do not overwrite existing files;
  • -j – ignore the archive structure and unpack everything into the current folder;
  • -q – output minimum information.
All the most basic options are considered, now let’s look at a few examples of working with the program in the terminal. To unzip zip linux to the current folder, type:
 unzip filename
And the extension is optional. You can test the archive using the -t option:
 unzip -tq
You can test all the archives in the current folder by running:
 unzip -tq \*.zip
If you need to unpack the archive not in the current folder, you can very simply specify the folder:
 unzip -d /tmp
Also, you can unpack the entire archive, but only the necessary files or files of the desired format:
 unzip \*.txt -d /tmp
With the -l option you can see the list of files in the archive:
 unzip -l
The unzip utility has been disassembled and now you will be able to do it exactly, but I said that we will consider several ways how to unpack ZIP in Linux. Therefore, we will talk further about the utility 7z.

Demonstration of zip and unzip utilities in the terminal:

How to unpack ZIP in Linux with 7Z

If you are a novice user then do not worry – we’ll talk about how to unpack ZIP in Linux in the easiest way.

 7z is a cross-platform set of utilities for working with archives. In addition to its own format, 7z, it supports a large number of other formats, including tar and zip. The advantage of this utility is that, in addition to the console interface, an item will be added to the context menu of the file manager, with which you can unpack or create archives.
To install the utility in Ubuntu or Debian, run:
 sudo apt install p7zip-full
And in Red Hat and CentOS:
sudo yum install p7zip
Now you can use the context menu of your file manager to unpack the zip linux archive. There will be a menu item 7zip, which will appear for the supported archives.
You can also use the program in the console. The syntax is very similar to unzip:
$ 7z command option archive_name
The command sets the desired action. We will be interested in only four teams:
  • e (Extract) – extract files from the archive;
  • x eXtract – extract files from the archive, saving the full path;
  • l (List) – list of archive files;
  • t (Test) – check the archive.
Now consider the most useful options:
  • -o – specify the folder to unpack;
  • -p – specify the password;
  • -x – do not extract these files;
  • -w – specify the working directory;
  • -y – answer positively to all questions;

Well, let’s look at some examples of working with the utility. First we look at the contents of the archive:
 7z l
Extract the archive preserving the structure of subdirectories:
 7z x
Or unpack all the files in one folder, ignoring subdirectories:
 7z e
Or you can specify the folder to which you want to extract the files using the -o option:
 7z x -o /tmp/

The final thought

Do you know how to unpack ZIP in Linux? – Tell us about this in the comments.

In this article, we discussed decompressing zip linux, as you can see, this is not much more complicated than unpacking standard tar archives. We have considered two methods and now you will know exactly what to do when you come across such a situation. If you have any questions, ask in the comments!


Add comment