How to Install 7-Zip on Ubuntu

7-Zip handles archive operations with high compression ratios and supports formats including 7z, ZIP, RAR, TAR, and GZIP. Whether you need to compress project backups before archiving them to external drives, extract downloaded software distributions, or verify archive integrity when transferring files across networks, 7-Zip provides the tools to accomplish these tasks efficiently from the command line.

This guide covers both the Ubuntu repository package and the official upstream binary, explains the differences between Ubuntu’s 7z command and the upstream 7zz binary, and walks through installation, usage examples, and troubleshooting. By the end, you will have a working 7-Zip installation ready for everyday compression tasks.

Choose Your 7-Zip Installation Method

Ubuntu provides multiple ways to install 7-Zip. Starting with Ubuntu 24.04, the official 7zip package replaced the older p7zip-full package (which is now transitional). The upstream binary from 7-Zip.org provides the absolute latest release with the 7zz command. All methods can coexist on the same system without conflicts.

MethodChannelVersionUpdatesBest For
APT (Ubuntu 24.04+)Ubuntu Repos23.01Automatic via apt upgradeMost users, desktop integration, automatic updates
APT (Ubuntu 22.04)Ubuntu Repos16.02Automatic via apt upgradeUbuntu 22.04 users preferring distro packages
Official Binary7-Zip.org25.01Manual reinstallationNewest features, upstream command syntax

For most users, the APT method is recommended because it provides automatic security updates and file manager integration with minimal maintenance. Only install from the official binary if you specifically need the latest upstream features or require a version newer than what Ubuntu provides.

These steps cover Ubuntu 22.04 LTS, 24.04 LTS, and 26.04 LTS. The APT package names differ between versions: Ubuntu 24.04 and newer use the 7zip package, while Ubuntu 22.04 uses p7zip-full. Commands are otherwise identical across supported LTS releases.

Update System Packages

Before installing any software, refresh your package index and apply pending updates. This ensures you get the latest available package versions and avoids dependency conflicts:

sudo apt update && sudo apt upgrade

Install 7-Zip from Ubuntu Repositories

For most users, the simplest installation method uses Ubuntu’s package manager. This approach provides automatic updates, file manager integration, and the standard 7z command that other applications expect.

Ubuntu 24.04 and Newer

Ubuntu 24.04 and later include the official 7zip package in the Universe repository. Install it with:

sudo apt install 7zip

This package provides the 7z command (version 23.01) and integrates with desktop file managers. After installation, verify it works:

7z
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
 64-bit locale=C.UTF-8 Threads:8 OPEN_MAX:1048576

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

If you previously had p7zip-full installed, Ubuntu 24.04 treats it as a transitional package that automatically pulls in the new 7zip package. You don’t need to uninstall anything; the transition happens seamlessly.

Ubuntu 22.04

On Ubuntu 22.04, use the p7zip-full package, which provides the same 7z command but at an older version (16.02):

sudo apt install p7zip-full

Verify the installation:

7z
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=C.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs)

While this version is older, it handles all common archive formats reliably and receives security updates through Ubuntu’s package system.

Install the Official 7-Zip Binary

If you need the absolute latest 7-Zip release with the newest compression improvements and format support, install the official binary directly from 7-Zip.org. This method provides the 7zz command (note the double z) and can run alongside the APT-installed 7z command without conflicts.

Most Ubuntu installations include curl by default, but minimal cloud images may omit it. If the download commands below fail with “command not found,” install curl first with sudo apt install curl.

Verify System Architecture

Before downloading, confirm your system architecture. The output determines which binary to download:

uname -m
x86_64

The output x86_64 indicates a 64-bit Intel or AMD system (the most common architecture). If you see aarch64, you have ARM64 hardware (such as Raspberry Pi or certain cloud instances). Most Ubuntu desktops and laptops run x86-64 architecture.

Download the Latest Release Automatically

This command parses the official download page and automatically fetches the latest x86-64 release. It works regardless of which version is current, so you don’t need to update the command when new releases appear:

cd ~/Downloads
curl -fsSLO "https://www.7-zip.org/$(curl -fsSL https://www.7-zip.org/download.html | grep -Eo 'a/7z[0-9]{4}-linux-x64\.tar\.xz' | head -n 1)"

This two-step command first queries the download page, extracts the latest Linux x64 filename using a regular expression, then downloads that file to your current directory.

For ARM64 systems, replace x64 with arm64 in the grep pattern. You can also download a specific version manually from the 7-Zip download page if you prefer not to use automatic detection.

Verify Download Integrity

For security-sensitive environments, verify the downloaded archive matches the official release. Calculate the SHA-256 checksum of your downloaded file:

sha256sum 7z*-linux-x64.tar.xz

Compare the output against the checksum listed on the official 7-Zip download page. The checksums change with each release, so you must check the current value on the website. If the checksums match character-for-character, the download is authentic and uncorrupted.

Extract and Install

While still in the Downloads directory, create an extraction directory, extract the archive, and test the binary before installing it system-wide:

mkdir -p ~/7zip-install
tar xf ~/Downloads/7z*-linux-x64.tar.xz -C ~/7zip-install
~/7zip-install/7zz
7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
 64-bit locale=C.UTF-8 Threads:8 OPEN_MAX:1048576, ASM

Usage: 7zz <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

<Commands>
  a : Add files to archive
  b : Benchmark
  d : Delete files from archive
  e : Extract files from archive (without using directory names)
  h : Calculate hash values for files
  i : Show information about supported formats
  l : List contents of archive
  rn : Rename files in archive
  t : Test integrity of archive
  u : Update files to archive
  x : eXtract files with full paths

Once you confirm the binary runs correctly, install it to /usr/local/bin. This directory is reserved for manually managed software and takes precedence over /usr/bin in the default PATH:

sudo install -m 755 ~/7zip-install/7zz /usr/local/bin/7zz

The extraction directory also contains 7zzs, a stripped variant with reduced executable size for space-constrained systems like embedded devices. Most users only need 7zz. If you need the stripped version, install it with sudo install -m 755 ~/7zip-install/7zzs /usr/local/bin/7zzs.

Verify the Installation

Confirm the binary is accessible from any directory by checking its location:

which 7zz
/usr/local/bin/7zz

Then verify it runs correctly:

7zz
7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
 64-bit locale=C.UTF-8 Threads:8 OPEN_MAX:1048576, ASM

Update the Official Binary

Unlike APT packages, the official binary requires manual updates. When new releases appear on the 7-Zip website, you can rerun the download and installation commands to upgrade. Alternatively, the following script automates this entire process:

cd ~/Downloads
rm -f 7z*-linux-x64.tar.xz
curl -fsSLO "https://www.7-zip.org/$(curl -fsSL https://www.7-zip.org/download.html | grep -Eo 'a/7z[0-9]{4}-linux-x64\.tar\.xz' | head -n 1)"
rm -rf ~/7zip-install
mkdir -p ~/7zip-install
tar xf ~/Downloads/7z*-linux-x64.tar.xz -C ~/7zip-install
sudo install -m 755 ~/7zip-install/7zz /usr/local/bin/7zz
7zz 2>&1 | head -2

This script removes old downloads, fetches the latest release, extracts it, and installs the updated binary. The final command displays the new version to confirm the update succeeded.

Common 7-Zip Commands and Usage Examples

7-Zip uses single-letter subcommands for common operations: a (add/create), x (extract with paths), l (list), u (update), and t (test integrity). The examples below cover everyday compression tasks. If you installed the APT package, use 7z instead of 7zz in these commands.

Create an Archive

Create new archives with the a (add) command. The format is determined by the file extension you specify:

7zz a archive.7z file.txt

This command creates an archive named archive.7z containing file.txt. You can add multiple files or entire directories:

7zz a project-backup.7z ~/Documents/project/

7-Zip automatically preserves file permissions and directory hierarchies. For maximum compression, add the -mx=9 flag (ultra compression level):

7zz a -mx=9 archive.7z large-file.iso

Extract an Archive

Extract archives while preserving directory structure with the x command:

7zz x archive.7z

This extracts all contents to the current directory, maintaining the original folder structure. To extract to a specific location, use the -o flag (no space between the flag and path):

7zz x archive.7z -o/tmp/extracted/

7-Zip automatically detects the archive format, so this command works for ZIP, RAR, TAR, GZIP, and other supported formats.

List Archive Contents

Preview archive contents without extracting using the l (list) command:

7zz l archive.7z

The output displays filenames, compressed and uncompressed sizes, and modification dates. This helps you verify archive contents or check compression ratios before extraction.

Update an Existing Archive

Add new files or replace modified files in existing archives with the u (update) command:

7zz u archive.7z updated-file.txt new-file.txt

This adds new-file.txt and replaces updated-file.txt if it already exists in the archive. Files that haven’t changed remain untouched.

Test Archive Integrity

Verify archive integrity after downloads or file transfers with the t (test) command:

7zz t archive.7z

The command verifies all files within the archive and reports “Everything is Ok” if the archive is intact. If corruption is detected, 7-Zip displays specific error messages identifying the affected files. Always test important archives before relying on them for backups.

Fix Common 7-Zip Installation Problems

Unsupported Architecture Error

If 7-Zip fails to run with “cannot execute binary file: Exec format error,” you downloaded the wrong architecture. First, verify your system architecture:

uname -m
x86_64

Systems showing x86_64 need the x64 version, while aarch64 systems require the ARM64 version. Remove the incorrect binary and download the correct one:

sudo rm /usr/local/bin/7zz

Command Not Found After Installation

If the 7zz command returns “command not found” after installation, first verify the binary exists:

ls -l /usr/local/bin/7zz
-rwxr-xr-x 1 root root 2878000 Aug  3 10:08 /usr/local/bin/7zz

Should the file exist but the command still fail, check that /usr/local/bin is in your PATH:

echo $PATH | grep -o '/usr/local/bin'
/usr/local/bin

When the directory is not listed, add it to your shell configuration:

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Zsh users should update ~/.zshrc instead. After reloading the configuration, confirm the shell finds the binary with which 7zz.

Permission Denied Errors

If you encounter permission errors when running 7zz, verify the binary has executable permissions:

sudo chmod +x /usr/local/bin/7zz

Old Version Shows After Upgrade

If 7zz shows an outdated version after reinstalling, the shell cached the old binary location. Clear the hash table to force the shell to find the updated binary:

hash -r
7zz 2>&1 | head -2

This issue only affects the current terminal session. New terminals will use the updated binary automatically.

Archive Corruption During Download

If extraction fails with “Can not open the file as archive” or similar errors, the download may be corrupted. Delete the corrupted file and re-download:

cd ~/Downloads
rm -f 7z*-linux-x64.tar.xz
curl -fsSLO "https://www.7-zip.org/$(curl -fsSL https://www.7-zip.org/download.html | grep -Eo 'a/7z[0-9]{4}-linux-x64\.tar\.xz' | head -n 1)"

After downloading, verify the checksum against the value published on the official 7-Zip download page before attempting extraction again.

Remove 7-Zip

Removal steps depend on which installation method you used.

Remove APT Package

For the APT-installed package on Ubuntu 24.04 and newer:

sudo apt remove 7zip
sudo apt autoremove

On Ubuntu 22.04:

sudo apt remove p7zip-full
sudo apt autoremove

The autoremove command cleans up any dependencies that were installed automatically and are no longer needed.

Remove Official Binary

For the manually installed official binary, remove the system-wide binary and clean up the extraction directory:

sudo rm -f /usr/local/bin/7zz /usr/local/bin/7zzs
rm -rf ~/7zip-install
rm -f ~/Downloads/7z*-linux-x64.tar.xz

Verify removal by checking that the commands no longer exist:

which 7zz
which 7z

Both commands should return no output, confirming complete removal.

Conclusion

7-Zip provides powerful compression with support for 7z, ZIP, RAR, TAR, and GZIP formats. For most users, the APT package offers the best balance of convenience and functionality with automatic updates. If you need the absolute latest features, the official binary from 7-Zip.org gives you direct access to upstream releases through the 7zz command. Your Ubuntu system can now compress project backups efficiently, extract downloaded software distributions, and verify archive integrity using cryptographic checksums. For related compression workflows, explore extracting tar.gz and tar.xz archives or unzip command examples when working with standard archives.

1 thought on “How to Install 7-Zip on Ubuntu”

Leave a Comment

Let us know you are human: