How to Install and use 7zip in Linux

The daily use of a modern operating system means that at some point we will have to deal with compressed files. Winrar may be the best known by Windows users but other alternatives may even share similarities. This post will help you to install and use 7Zip in Linux which is a solid alternative that can work with many compressed formats.

7 ZIP

On the 7-Zip website we get the following definition:

7-Zip is a file archiver with a high compression ratio.

In other words, 7-zip is a compression format that aims to rival the RAR and ZIP formats. It is available for Windows and Linux and one of its main characteristics is that it has a high compression ratio which makes it quite attractive.

Other features of 7-zip are:

  • High compression ratio in 7z format with LZMA and LZMA2 compression
  • Supports a lot of formats
  • Strong AES-256 encryption in 7z and ZIP formats
  • Self-extracting capability for 7z format
  • Powerful File Manager
  • Powerful command-line version
  • Free and Open Source

In addition to all this, 7-Zip supports many different Linux distributions. That is to say, you will not have problems installing it.

Install 7Zip in Linux

Installing 7-Zip in Linux is very easy thanks to the support it gives to our favorite system. Therefore, it is available from the official repositories of almost any Linux distribution-

Then, for distributions like Debian, Ubuntu, and derivatives like Linux Mint or ElementaryOS, you just have to run:

sudo apt install p7zip-full p7zip-rar

In the case of Fedora, Red Hat Linux Enterprise and derivatives such as CentOS

sudo dnf install p7zip

And for OpenSUSE:

sudo zypper install p7zip

If you use Arch Linux and derivatives you can run:

sudo pacman -S p7zip

When the installation is finished, it is not necessary to restart so we can use the program.

Using 7zip in Linux

As soon as you install the above-mentioned packages, you will be able to compress and decompress files with the 7z format, which is the 7Zip format, from any Linux file manager.

But also the 7z command is enabled so we can use it from the terminal. Especially useful in the field of servers.

For example, if you want to decompress a file in 7z format run

7z e [7zip_file_path]

And to create a new archive you need to add the files. To do this, run the following syntax

7z a [outputfile] [file1] [file2]

And so on.

Compressing and decompressing can be a time-consuming process, but we can take advantage of the computer’s processor and tell 7zip to use more resources.

This is done by adding the -mmt option and specifying the number of processor threads to use for example:

7z a [outputfile] -mmt2 [file1] [file2]

A real case of this command is:

7z a k.7z -mmt2 index.png

Sample Output

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits
Scanning the drive:
 1 file, 17461 bytes (18 KiB)
 Creating archive: k3.7z
 Items to compress: 1
 Files read from disk: 1
 Archive size: 15156 bytes (15 KiB)
 Everything is Ok

The above command compresses the index.png file and adds it to k.7z

You can also use the -p option to add a password to the file.

7z to k.7z -mmt2 -p index.png

To list the files that are within a 7z file, run the command along with the l

7z l [7zfile]

To check the integrity of an archive:

7z t [7zfile]

So you can use the 7z command quickly and easily. Remember that you can specify the name of the file with the absolute path, otherwise, it is assumed to be in the same directory.

If you wish to consult more information, you can execute the help of the 7zip command

7z --help

Conclusion

7zip is a great program that has a format that is a wonder. With a very high compression rate and compatible with most Linux distributions, they make it accessible and quite useful for working with files. Now you know how to use and install it, you just have to try it on your computer.

So, have you used 7zip? did you know it? leave us a comment and share the post.

Share This: