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 walks through how to install 7-Zip on Ubuntu, covering both the default APT package and the official upstream binary.
Below you will find the differences between Ubuntu’s 7z command and the upstream 7zz binary, step-by-step installation for each method, practical usage examples, and troubleshooting for common issues. By the end, you will have a working 7-Zip installation ready for everyday compression tasks.
Choose Your 7-Zip Installation Method for Ubuntu
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.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| APT (Ubuntu 24.04+) | Ubuntu Repos | Distribution default | Automatic via apt upgrade | Most users, desktop integration, automatic updates |
| APT (Ubuntu 22.04) | Ubuntu Repos | Distribution default (legacy) | Automatic via apt upgrade | Ubuntu 22.04 users preferring distro packages |
| Official Binary | 7-Zip.org | Latest stable | Manual reinstallation | Newest 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 26.04 LTS, 24.04 LTS, and 22.04 LTS. The APT package names differ between versions: Ubuntu 24.04 and newer use the
7zippackage, while Ubuntu 22.04 usesp7zip-full. Commands are otherwise identical across supported LTS releases.
Update Ubuntu 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
This guide uses
sudofor commands that need root privileges. If your user account is not in the sudoers file, run the commands as root or follow the guide on how to add and manage sudo users on Ubuntu.
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-fullinstalled, Ubuntu 24.04 treats it as a transitional package that automatically pulls in the new7zippackage. 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
x64witharm64in 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 need7zz. If you need the stripped version, install it withsudo 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 7-Zip Binary
Unlike APT packages, the official binary requires manual updates. When new releases appear on the 7-Zip website, rerun the download and installation commands to upgrade. The following script automates this process and displays the installed version when complete:
#!/bin/bash
set -e
# Remove old downloads
rm -f ~/Downloads/7z*-linux-x64.tar.xz
# Download the latest release
echo "Downloading latest 7-Zip release..."
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)"
# Extract and install
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
# Verify
echo "Update complete:"
7zz 2>&1 | head -2
The set -e flag causes the script to stop immediately if any command fails, preventing a broken binary from being installed. The final output confirms the new version.
Common 7-Zip Commands and Usage Examples
7-Zip uses single-letter subcommands for common operations. The table below summarizes the most useful commands, followed by detailed examples for each. If you installed the APT package, use 7z instead of 7zz in these commands.
| Command | Action | Example |
|---|---|---|
a | Create a new archive or add files | 7zz a archive.7z files/ |
x | Extract with full directory paths | 7zz x archive.7z |
e | Extract without directory structure | 7zz e archive.7z |
l | List archive contents | 7zz l archive.7z |
u | Update existing archive with changed files | 7zz u archive.7z newfile.txt |
t | Test archive integrity | 7zz t archive.7z |
d | Delete files from archive | 7zz d archive.7z oldfile.txt |
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.
Troubleshoot 7-Zip Installation Issues on Ubuntu
Unsupported Architecture Error
If 7-Zip fails to run, you may see an error like the following:
bash: /usr/local/bin/7zz: cannot execute binary file: Exec format error
This means you downloaded the binary for the wrong architecture. 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 from Ubuntu
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 resolve:
which 7zz && echo "still installed" || echo "removed"
which 7z && echo "still installed" || echo "removed"
removed removed
Both commands returning “removed” confirms complete removal from your system.
The 7z command comes from the Ubuntu APT package (7zip on 24.04+ or p7zip-full on 22.04) and integrates with desktop file managers. The 7zz command comes from the official upstream binary downloaded from 7-Zip.org and provides the latest release. Both can coexist on the same system without conflicts.
Yes. Ubuntu 24.04 and newer include the 7zip package in the Universe repository, which provides the 7z command. Ubuntu 22.04 provides the older p7zip-full package with the same 7z command at version 16.02. Both install directly with apt install.
Yes. 7-Zip supports extracting RAR archives (including RAR5 format) along with ZIP, TAR, GZIP, XZ, BZIP2, and many other formats. However, 7-Zip cannot create RAR archives because the RAR compression algorithm is proprietary. Use the 7zz x archive.rar command for extraction.
Conclusion
With 7-Zip now set up on your system, you can compress project backups efficiently, extract downloaded software distributions, and verify archive integrity using cryptographic checksums. For most users, the APT method is the simplest way to install 7-Zip on Ubuntu since it provides automatic security updates and file manager integration. 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. For related compression workflows, explore extracting tar.gz and tar.xz archives or unzip command examples when working with standard archives.
Thanks