Dominate compressed files on Linux with 7-Zip

0
182

Compressed files are very common on the Internet. Thanks to them we can reduce the size of the files when we are going to work with them and, in addition, we will be able to group a large number of these in a single package so that it is easier to download and share them. In order to work with these compressed files, it is necessary to use a specific program for this purpose. And one of the best known that we can find is 7-Zip. But does this file compressor work on Linux?

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 and LZMA2 compression algorithms, has an AES-256 data encryption system, and is also capable of compressing and decompressing other compressed file formats, such as ZIP, GZIP or RAR, among others, without any problems. 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 we are going to see how to get 7-Zip up and running 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 are going to use Ubuntu as an example, the most widely 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

We will now 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 Fedora, or any distro based on it, the command to install this compressor is the following:

sudo yum install p7zip p7zip-plugins

And, of course, we couldn’t forget about Arch Linux either. 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, to compress a file, we’ll need to use the a parameter, along with the name of the compressed file and the file, or directory, 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 SZ_comprimido.zip SoftZone/

Did you forget to add a file to the compressed archive? Nothing happens. Using the u parameter we will be able to add the files we want to the already created compressed file 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 to decompress 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 the 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 commands aren’t your thing, we should know that 7-Zip also has a graphical interface, or GUI, from which we’ll be able to both compress and decompress files using the mouse, just like we can do on 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.

Previous articleThe best Spotify tricks and secrets to get the most out of it
Next articleDo you need to install Microsoft Teams on Linux? So can