Dominate compressed files on Linux with 7-Zip

7-Zip is a file compressor that has its own compression engine (which bears the same name) completely free and open source. Thanks to it we will be able to compress our files in the .7z format, and open any file that has been compressed in this format. This program makes use of the LZMA compression algorithms and LZMA2it has an AES-256 data encryption system and, in addition, it is capable of compressing and decompressing other compressed file formats without problems, such as ZIP, GZIP or RARamong many others.

Although operating systems (such as Linux distros) are capable of working with compressed files natively, without having to install anything, generally the only format they usually support is .zip. Therefore, if we want to work with other formats, both to compress and decompress, we will have to install another file compressor on the PC.

And then let’s see how launch 7-Zip on a Linux system.

Install 7-Zip on Linux

7-Zip is made up of three different packages on Linux distros:

  • p7zip: a package that only adds support for the .7z format, but nothing else. It is the smallest and lightest.
  • p7zip-full: A more complete package that adds new algorithms to further reduce the size of certain types of files, such as audio files.
  • p7zip-rar: adds support for 7-Zip to work with RAR archives.

We recommend you install the second and third. In this way we will be able to have a fully functional 7-Zip, with all its features and, in addition, we will be able to use it to open .rar files without having to install more separate programs.

The process to install this file compressor is practically the same in all distros, adapting the commands, yes, the package manager that we use. In our case we will use as an example Ubuntu, the most used distro in the world. Also, these same commands would work for any other distro based on it.

In Ubuntu, this compressor is included in the “universe” repositories. Therefore, the first thing we will do is enable it (if we don’t already have it, although it comes by default) with the following command:

sudo add-apt-repository universe && sudo apt update

Now we will install this file compressor using the apt package manager. To do this, again in a terminal, we will execute:

sudo apt install p7zip-full p7zip-rar

Install 7-Zip Ubuntu

When the process is finished, we will have the compressor installed and ready to use it.

In case of using fedoraor any distro based on it, the command to install this compressor is as follows:

sudo yum install p7zip p7zip-plugins

And, of course, we could not forget either ArchLinux. To install 7-Zip on Arch, Manjaro, or any distro based on it, we will have to execute:

sudo pacman -S p7zip

How does the compressor work?

7-Zip can be used in two different ways. The first one is through commands through a terminal. To do this, we are going to use the “7z” command, which is the binary that allows us to use it. And then we will accompany you with the corresponding parameters.

For example, for compress a file, we will have to use the a parameter, along with the name of the compressed file and the file, or directory, that we want to compress. For example, to compress a folder called “SoftZone” into a file called “SZ_compressed.7z”, the command would be the following:

7z a SZ_comprimido.7z SoftZone/

If we also add the “-t” parameter together with another compressed file format, we can create an archive in another format. For example, for the previous example, if instead of 7z we want to use the classic “zip”, the command would be as follows:

7z a -tzip SoftZone/

Did you forget to add a file to the compressed archive? Nothing happens. Using the parameter u we will be able to add the files we want to the compressed file already created without having to do anything else. For example, to add the two text files “SZ1.txt” and “SZ2.txt”, the command that we will have to execute is the following:

7z u SZ_comprimido.7z SZ1.txt SZ2.txt

In the case of already having our compressed file, if what we want is unzip it, we will have to do it using the “e” parameter, followed by the name of the compressed file. For example:

7z e SZ_comprimido.7z

We can also see a list with all files that we have inside the compressed file very quickly and easily using the “l” parameter next to the file name:

7z l SZ_comprimido.7z

Finally, we can also use the “-p{}” parameter to add a password to the archive and protect it. Thus, starting from the example of creating a new file, we can protect it with the password “1234” as follows:

7z a -p{1234} SZ_comprimido.7z SoftZone/

If the commands are not our thing, we should know that 7-Zip also has a graphical interface, or GUI, from which we will be able to both compress and decompress files using the mouse, just as we can do it in Windows or macOS. To open this interface, what we must do is install the following package, which will be the one that enables the interface (it is not found inside apt, so we have to use “snap”):

sudo snap install p7zip-desktop

Once installed, we can find access to the program’s interface in the list of installed programs, as one more tool. And, by clicking on it, we can see the well-known 7-Zip interface.

7-Zip Linux interface

It’s not the prettiest interface, and it’s not the most up-to-date either. But at least it works without problems and will allow us to work with these compressed files without having to memorize a single terminal command.

Related Articles

Leave a Reply

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