How to Install 7-Zip on Ubuntu

If you want to install 7-Zip on Ubuntu, the quickest option on Ubuntu 22.04 and 24.04 LTS is sudo apt install p7zip-full p7zip-rar. On Ubuntu 26.04 LTS, use sudo apt install 7zip 7zip-rar instead because the package names changed with that release. Both methods provide the 7z command-line utility together with support for extracting RAR archives. Ubuntu does not include the Windows graphical interface, but after the required packages are installed, archives can be managed both from the terminal and through the default file manager.

7-Zip is a popular archive utility recognized for its high compression efficiency with the .7z format. On Linux, Igor Pavlov’s project is available in two forms: the community-maintained p7zip port included in Ubuntu repositories and the official console versions distributed since 2022, which use the 7zz executable. This guide explains both installation approaches, frequently used commands, archive format options, and common troubleshooting steps.

Version note: The commands in this guide were validated with Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS (Resolute Raccoon). Starting with 26.04, apt installs the official 7zip package, providing 7-Zip 26.00, instead of the older p7zip port. The RAR extension is also called 7zip-rar rather than p7zip-rar. The 7z commands shown below were successfully tested on a clean Ubuntu 26.04 cloud system. When using an Ubuntu-derived distribution, verify the appropriate package names in the documentation supplied by that distribution.

Key takeaways

  • Install p7zip-full when you need the 7z and 7za executables. The smaller p7zip package only includes 7zr, which is limited to .7z archives and can therefore result in “unsupported archive” errors when working with ZIP or TAR files.
  • Install p7zip-rar on Ubuntu 22.04 and 24.04, or 7zip-rar on Ubuntu 26.04, if you need to open .rar files. RAR functionality is separated from the main archive package because of licensing restrictions associated with the format.
  • Use 7z x archive.7z when extracting an archive while preserving its directory structure. Use 7z e archive.7z when every extracted file should be placed directly in the current directory.
  • If you need the newest functionality supplied by the upstream developer, obtain the official Linux release from 7-zip.org and run the 7zz executable.
  • On Ubuntu Desktop, File Roller, also known as Archive Manager, can create and extract .7z archives after p7zip-full has been installed.

Prerequisites

Before installing 7-Zip on Ubuntu, make sure the following requirements are available:

  • An Ubuntu system with sudo privileges, or a user account that allows binaries from the official build to be installed inside ~/bin.
  • Network connectivity to Ubuntu package mirrors for apt, or browser access for downloading the official archive.
  • Basic experience with terminal commands. If you are unfamiliar with the shell, review an introductory Linux terminal guide together with an introduction to basic Linux concepts.

For additional background on package management, consult a guide covering package administration with Apt on Ubuntu and Debian. When configuring a new VPS, complete the initial Ubuntu server setup before installing archive utilities.

Understanding the 7-Zip packages available on Ubuntu

Ubuntu separates 7-Zip functionality into multiple apt packages. Selecting an unsuitable package is a common reason an installation appears successful even though ZIP or RAR files still cannot be processed.

p7zip vs p7zip-full vs p7zip-rar

Package Binaries installed Typical use Ubuntu releases
p7zip 7zr Minimal workflows limited to .7z files 22.04, 24.04
p7zip-full 7z, 7za General command-line use with ZIP, TAR, GZIP, BZIP2, XZ, and additional formats 22.04, 24.04; transitional on 26.04
p7zip-rar RAR plugin for 7z Opening many .rar archives 22.04, 24.04

For nearly every use case on Ubuntu 22.04 or 24.04, install p7zip-full. Add p7zip-rar if you also expect to work with .rar archives.

Ubuntu 26.04 LTS package names

Ubuntu 26.04 switched to the upstream 7zip source package. The older names p7zip-full and p7zip are now virtual packages that are fulfilled by 7zip.

Package Binaries installed Typical use
7zip 7z, 7za, 7zr General command-line usage with 7-Zip 26.00 from Igor Pavlov
7zip-rar RAR plugin for 7z Opening many .rar archives

On Ubuntu 26.04, running apt install p7zip-full continues to work because it installs 7zip. However, p7zip-rar is not available on that release. Install 7zip-rar when RAR support is required.

The community-maintained p7zip version hosted on SourceForge remains useful for older Ubuntu LTS releases. With Ubuntu 26.04, the packages available through apt follow the official 7-Zip source more closely, so downloading 7zz manually may not be necessary unless you specifically require a newer point release than the repository provides.

The official 7-Zip Linux binary: 7-Zip 21.x and later

Since 2022, Igor Pavlov has distributed official Linux console versions through 7-zip.org. Current releases, such as 7-Zip 26.01, are supplied as tarballs containing 7zz, which is dynamically linked, and 7zzs, which is statically linked. These executables can provide newer format support and fixes before they become available through older Ubuntu p7zip packages.

Choose the official build when you require the latest archive format support, want to compare functionality with the Windows edition of 7-Zip, or do not have access to sudo and prefer installing the program only for your user account. Choose p7zip-full when you prefer the software to remain completely managed through apt.

Step 1: Update your package index

Refresh the package index before installation so that apt can resolve current versions of p7zip-full and p7zip-rar:

Updating the package information first also helps prevent version mismatches when other packages on the system have recently been upgraded.

Step 2: Install 7-Zip using apt

Select the installation command that corresponds to your Ubuntu release.

Ubuntu 22.04 and 24.04 LTS

Install the primary tools and the RAR extension together:

sudo apt install p7zip-full p7zip-rar

This installs the 7z executable used throughout the examples below. On these Ubuntu versions, 7z identifies itself as a p7zip build, for example 7-Zip [64] 16.02.

Ubuntu 26.04 LTS and later

Install the official 7zip package together with its RAR extension:

sudo apt install 7zip 7zip-rar

On Ubuntu 26.04, sudo apt install p7zip-rar returns Unable to locate package because the package was renamed to 7zip-rar. The command sudo apt install p7zip-full still works on 26.04 because it installs 7zip, but RAR support must be added with 7zip-rar.

After installation, the 7z command on Ubuntu 26.04 reports 7-Zip 26.00 from Igor Pavlov.

Verify the installation

Check that the executables are available through your PATH and display the installed version:

The expected output contains a version line followed by a list of supported archive formats. Examples from validation include:

  • Ubuntu 22.04 / 24.04: 7-Zip [64] 16.02, supplied by the community p7zip build.
  • Ubuntu 26.04: 7-Zip 26.00 (arm64) or 7-Zip 26.00 (x86), supplied by the official 7zip package.

If you need to diagnose an incomplete or damaged installation, list the installed executable files:

dpkg -L 7zip 2>/dev/null | grep bin/ || dpkg -L p7zip-full | grep bin/

Step 3: Install the official 7-Zip binary as an alternative

If you require a newer point release than the version supplied by your apt repositories, or if sudo is unavailable, download the tarball that matches your processor architecture from 7-zip.org. The following example uses the 64-bit x86-64 package for version 26.01. Ubuntu 26.04 already provides 7-Zip 26.00 through apt install 7zip, so this manual installation is optional unless version 26.01 is specifically required.

Download the official 7-Zip Linux release

cd /tmp
curl -LO https://github.com/ip7z/7zip/releases/download/26.01/7z2601-linux-x64.tar.xz

If your system uses ARM hardware, replace the URL with 7z2601-linux-arm64.tar.xz or another appropriate build.

Extract and move the binary to your PATH

tar -xf 7z2601-linux-x64.tar.xz
sudo install -m 755 7zz /usr/local/bin/

For an installation that does not require sudo, place the executable in a directory owned by your user account:

mkdir -p ~/bin
install -m 755 7zz ~/bin/
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Verify the official binary version

The header should display 7-Zip 26.01. When using this installation method, replace 7z with 7zz in the command examples that follow.

How to use 7-Zip on Ubuntu: core commands

The standard command syntax is:

7z <command> [<switches>] <archive> [<files>]

Frequently used commands include a for adding files to an archive, x for extracting files while retaining directory paths, e for extracting without paths, and l for listing archive contents. Run 7z without arguments to display the complete command list supported by the installed version.

Extract an archive

Use x when directory paths should be retained:

To extract every file directly into the current directory without preserving paths, use:

To extract the contents into a specified directory, run:

7z x archive.7z -o./output_dir

Create a compressed archive

Add one file to a newly created .7z archive:

Add an entire directory recursively:

7z a backup.7z /path/to/project/

Create a ZIP archive when the files need to be shared with software that expects the .zip format:

7z a -tzip archive.zip file1.txt file2.txt

List archive contents without extracting

Include -slt when detailed technical information about each archive entry is required:

Add password protection to an archive

7z a -psecret secure.7z sensitive.txt

Extract a password-protected archive with:

Replace secret with a strong password. On systems that retain shell command history, prefer specifying only -p without placing the password directly on the command line. The shell will then request the password interactively.

Split a large archive into multiple parts

Create archive volumes of 100 megabytes:

7z a -v100m large.7z big.iso

The result includes files such as large.7z.001, large.7z.002, and additional numbered parts. To extract the archive later, start with the first volume:

Batch compression from the terminal

Compress every .log file located in the current directory:

When handling large collections of files located throughout the filesystem, combine find with 7-Zip. File-search patterns produced by find and locate can be incorporated into archive workflows.

Compress and extract files with the file manager

On Ubuntu Desktop, open Files, also known as Nautilus, right-click a file or directory, and select Compress or Extract Here. GNOME Archive Manager can process .7z archives once p7zip-full is installed. This provides a graphical workflow similar to the Windows experience without requiring a separate 7-Zip desktop program.

Compression format comparison

Format Typical command Strengths Tradeoffs
.7z 7z a archive.7z files/ Strong compression and encryption Slower and not supported by every operating system by default
.zip 7z a -tzip archive.zip files/ Broad compatibility Usually provides less compression than .7z
.tar.gz tar -czf archive.tar.gz files/ Native Linux workflow with fast tooling Uses a two-stage convention; tar is commonly preferred for Linux-only pipelines

Select 7z when you control both ends of the file transfer and want to reduce archive size. Select zip when recipients need a container with broad Windows compatibility. Select tar.gz when GNU tar is already the standard tool used for backups and deployment processes. Additional tar usage can be found in guides covering the Linux tar command.

Compared with xz, zstd, and bzip2, 7-Zip is designed as an all-in-one archive solution that can combine multiple files while also supporting optional encryption and split volumes. Native compression utilities may perform better in terms of speed or compression ratio for individual data streams, but they do not replace a complete archiver when multiple files need to be combined into a single package.

Troubleshooting common issues

Command not found after installation

If the shell displays 7z: command not found, either the package installation may have failed or /usr/bin may be missing from your PATH. Reinstall the package and verify the command:

sudo apt install --reinstall p7zip-full
command -v 7z

If 7zz was installed manually, verify that /usr/local/bin or ~/bin is included in the output of echo $PATH.

Cannot open output file errors

Extraction can fail with permission-related errors if the destination directory is not writable or if the filesystem does not have enough free storage. Extract the archive into a directory owned by your user account:

7z x archive.7z -o"$HOME/extracted"

Before extracting very large archives, check the available disk capacity with df -h.

Unsupported method errors when opening RAR files

Install the appropriate RAR extension for the Ubuntu release you are using:

sudo apt install p7zip-rar

On Ubuntu 26.04, use sudo apt install 7zip-rar instead.

Some newer versions of the RAR format may still fail because of changes to the archive format. If that happens, try the official 7zz version available from 7-zip.org, which follows Igor Pavlov’s latest decoder implementations.

FAQs

1. How do I install 7-Zip on Ubuntu?

First refresh the package lists, then install the packages intended for your Ubuntu version:

sudo apt update
sudo apt install p7zip-full p7zip-rar

On Ubuntu 26.04 LTS, use sudo apt install 7zip 7zip-rar instead.

Confirm the installation by running 7z. On Ubuntu desktop systems, Archive Manager can also be used after the installation has completed.

2. Is 7-Zip available on Linux?

Yes. Linux users can obtain the community p7zip packages through apt or download the official 7zz console release from 7-zip.org. The 7-Zip project does not provide an official Linux graphical interface, although desktop environments can integrate the command-line tools with their file managers.

3. Does 7-Zip work on Ubuntu?

Yes. On Ubuntu 22.04 and 24.04, 7-Zip is available through p7zip-full. Ubuntu 26.04 provides it through the 7zip package. The official 7zz tarball can also be used when a newer point release is required than the version available through apt. All of these installation methods work with current Ubuntu LTS releases without requiring additional compilers or build procedures.

4. What is the alternative to 7-Zip in Ubuntu?

Typical alternatives include File Roller using p7zip backends for straightforward graphical tasks, PeaZip as a cross-platform desktop application, and native utilities including tar, gzip, and zstd for compression workflows that do not require the .7z container. Many teams use tar.gz for Linux-only backups and add 7-Zip when files must also be exchanged with Windows users.

5. How do I extract a .7z file on Ubuntu from the terminal?

After installing p7zip-full, run:

Use 7z e filename.7z only when every extracted file should be placed directly in the current directory without retaining any subdirectories.

Conclusion

7-Zip can be installed on Ubuntu 22.04 and 24.04 with p7zip-full and p7zip-rar, while Ubuntu 26.04 LTS uses 7zip together with 7zip-rar. The official 7zz executable can also be installed when a newer point release is needed than the version available from the package repositories. With these tools, you can create archives, inspect their contents, protect files with passwords, divide large archives into multiple volumes, and work with compressed files from either the terminal or the desktop file manager.

Source: digitalocean.com

Create a Free Account

Register now and get access to our Cloud Services.

Posts you might be interested in: