How to Extract 7z Archives on Linux

In this tutorial, we will show you a simple way to extract 7z archives on Linux.

Linux Extract 7z Archive

A 7z file is an open format for archiving files that supports more modern and more efficient compression methods such as LZMA and LZMA2.

The usage of 7z has slowly increased thanks to its great compression ratio and its support for AES-256 compression. It has continued to improve and offer better solutions to some of the other compression archival formats, such as zip.

There are two downsides of using 7zip that are worth mentioning. One of those is that 7zip does not offer error correction. Basically, this means if bits get corrupted, 7zip will not be able to attempt to correct these.

The other issue, which is mainly for Linux users, is that 7zip does not store ownership permissions. Just be aware of this when extracting a 7zip backup. If you are making these backups yourself, you should archive them with a tool like tar before compressing with 7zip.

Luckily, extracting these 7z archives is a relatively easy process on Linux thanks to a variety of tools that implement the 7zip file architecture.

Over the following sections, we will show you how to install a tool to extract these 7zip files on Linux, as well as showing you how to use said tool to extract a 7z archive.

In particular, we will be showing you how to install and use the official 7zip tool, which has been ported to Linux. We also offer an alternative method in the older p7zip fork.

Extracting a 7z File on Linux

The following steps have been written with a focus on Debian-based Linux systems such as Ubuntu or Raspberry Pi OS. These steps should work with slight adjustments on other Linux distributions. All you need to do is adjust the installation method. The actual extraction steps are the same.

Additionally, we will be using the terminal for all of the steps. If you use a desktop version of Linux, you can often open the terminal by pressing CTRL + ALT + T on your keyboard.

Installing a Compatible 7z Archive Tool on Linux

1. Before we can install the tool we will use to extract the 7z archive on our Linux system, we should update our system.

You can update the package cache and upgrade any packages that may be out-of-date by running the following two commands within the terminal.

sudo apt update
sudo apt upgrade

2. Once the package list cache has been updated, we can install the 7zip to our Linux system by running the following command.

7zip is a fairly widespread tool, so it should be available in almost any Linux package repository.

sudo apt install 7zip

If you are running RHEL or Feodra, you should be able to install this same tool by running the command below.

dnf install 7zip

Alternatively, if you are running Alpine Linux, you can install the 7z extraction tool using the following command.

apk add 7zip

Troubleshooting: If you are running into a package not found error. Then. you will be required to install the older p7zip fork instead. Just change “7zip” with “p7zip” in the above command.

Using p7zip to Extract an 7z Archive

3. Now that you have 7zip installed on your Linux system, we can use it to extract a 7z archive.

Extracting an archive is incredibly simple with this tool. All you need to do is use “7z” followed by the letter “x” and, finally, the path to the archive you want to extract.

You can see the basic syntax of extracting a 7z archive below. On a random note, this command will also allow you to extract other archive formats supported by 7zip such as “rar” and “zip“.

7z x <FILETOEXTRACT>

Please note that depending on your operating system, you may have to use “7zz” instead of “7z“. This is due to older operating systems offering p7zip and the official 7zip application. Newer releases have dropped p7zip, meaning you can now use “7z” on those.

4. To give you an example of how this works, we will use the 7zip utility to extract a 7z archive called “pimylifeup.7z” on our Linux system.

To do this, we use “7z” followed by “x” and finally the path to the file in our home directory.

7z x /home/pimyubu/pimylifeup.7z

Below, you can see the sort of output that you will get after extracting an archive.

7-Zip (z) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26
 64-bit locale=en_AU.UTF-8 Threads:24

Scanning the drive for archives:
1 file, 409 bytes (1 KiB)

Extracting archive: pimylifeup.7z
--
Path = pimylifeup.7z
Type = 7z
Physical Size = 409
Headers Size = 207
Method = LZMA2:12
Solid = -
Blocks = 3


Would you like to replace the existing file:
  Path:     ./example1.txt
  Size:     48 bytes (1 KiB)
  Modified: 2024-05-21 21:59:49
with the file from archive:
  Path:     example1.txt
  Size:     48 bytes (1 KiB)
  Modified: 2024-05-21 21:59:49
? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? A

Everything is Ok

Files: 3
Size:       190
Compressed: 409

Conclusion

Hopefully, by this point in the guide, you will understand how to quickly and easily extract a 7z archive on a Linux system.

Extracting these archives has become easier over time as more tools have been ported to Linux. Luckily for newer users, even the official 7zip has been ported across, meaning compatibility and functionality should be at its best.

Please feel free to comment below if you have had any issues extracting a 7z archive.

If you like this tutorial, we recommend checking out our many other Linux guides.

Leave a Reply

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