7zip ubuntu

The GNOME Archive Manager, also called File Roller, uses p7zip as the backend. This means you can create and extract .7z archives from the File Manager by default.

CLI usage is a different story. There are three CLI versions of p7zip (p7zip, p7zip-full, and p7zip-rar). You have to install these manually to manage .7z archives from the terminal.

Although p7zip is an unofficial POSIX fork, it has still been the preferred option for Ubuntu users for a long time. But this is changing.

7-Zip 21.0 alpha introduced native CLI support for Linux in 2021. This means you also have the option to use the official port now.

Manage .7z Archive from GUI

The graphical archive tool is very intuitive. For starters, select the files you want to archive, right-click and select Compress. Then, select .7z as the archive format.

Unpacking a .7z archive is just as easy. Simply right-click the archive and select Extract.

If you want to perform other tasks like adding or removing files from the archive, searching through the archive, testing integrity, and so on, you can select Open with Archive Manager instead.

Install Official 7-Zip Port (CLI)

The p7zip project was last updated in 2016. As such, the official 7zip package is the preferred way to install 7-Zip. You can install it directly from the Ubuntu Universe repo with

sudo apt install 7zip

After installing it, you can get a description of commands and switches by entering

7zz

As for actual usage, the basic syntax is

7zz <command> <optional-switches> <archive> <files>

For instance, the following command adds the files named doc and image to an archive named newarchive.

7zz a newarchive doc.txt image.png

The following command extracts the files while preserving the directory structure. We’ve also used the -o flag to specify an output directory called SampleFolder instead of extracting in the current directory.

7zz x -oSampleFolder newarchive.7z

You can run 7zz again to list all the commands and options available. With those, you can delete or rename files in the archive, test the integrity, and so on, the same as the GUI version.

Install and Use p7zip (CLI)

If you prefer sticking with the traditional p7zip utility, you can install it with

sudo apt install p7zip-full

You’ll want to install the p7zip-rar package as well if you’re going to deal with .rar archives.

sudo apt install p7zip-rar

After installing it, you can check the commands and options available with

7z

Its usage is the same as the official version, you’re only using 7z in place of 7zz. As such, you can check the previous section for reference.

Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.