How To Install 7-Zip on Ubuntu 26.04 LTS

Install 7-Zip on Ubuntu 26.04

If you work with compressed archives on Linux, you already know that not every tool handles every format. Ubuntu 26.04 LTS does not ship with 7-Zip installed, which means the moment you receive a .7z backup from a client or need to compress a 4GB database dump before uploading it to object storage, you are stuck. This guide walks you through exactly how to install 7-Zip on Ubuntu 26.04 LTS, covering both the APT repository method and the official upstream binary, so you can choose the right fit for your workflow.

7-Zip is a free, open-source file archiver built around the LZMA2 compression algorithm. It consistently outperforms ZIP and gzip on text-heavy data like logs, configuration files, and source code, often reducing file sizes by 30 to 70 percent. Beyond raw compression, it supports reading and writing over 15 archive formats including 7z, ZIP, TAR, GZIP, BZIP2, XZ, and ISO, plus extraction of RAR archives.

Ubuntu 26.04 LTS, codenamed Resolute Raccoon, ships with GNOME 50, runs Wayland by default, and continues the package naming change introduced in Ubuntu 24.04: the old p7zip-full package is now a transitional stub, and the correct package to install is simply 7zip. If you have older scripts or documentation pointing at p7zip-full, this guide clarifies exactly what changed and why updating your commands matters.

By the end of this tutorial, you will have a working 7-Zip installation, understand the difference between the 7z and 7zz commands, know how to run the most common archive operations, and have a troubleshooting reference for the errors most people hit during setup.

What Is 7-Zip and Why Does It Belong on Your Ubuntu Server?

Before touching the terminal, it helps to understand what you are actually installing and why it makes sense on Ubuntu 26.04 specifically.

7-Zip uses LZMA2 as its primary compression algorithm. LZMA2 works by finding repeating byte patterns across a large sliding window of data (up to 4GB in ultra mode) and encoding them as back-references rather than storing each byte individually. The result is archives that are significantly smaller than what ZIP or gzip produce on the same input, without sacrificing decompression speed.

This matters in practical terms. A 1GB Nginx log directory that compresses to 95MB with gzip will often compress to 40MB with 7-Zip at its default settings, and to under 30MB at maximum compression. When you multiply that across hundreds of daily backup jobs or automated log rotations running on a production server, the storage and egress cost difference adds up fast.

On Ubuntu 26.04, 7-Zip also integrates with the Nautilus file manager when you install the APT package, which gives desktop users right-click archive creation and extraction without additional plugins.

Prerequisites

Before running any commands, confirm your environment meets these requirements:

  • Operating System: Ubuntu 26.04 LTS (Resolute Raccoon), desktop or server edition
  • User Privileges: A user account with sudo access. All package installation and binary placement commands write to protected system directories.
  • Internet Connection: Required for the APT method and the upstream binary download.
  • curl installed: Required for the upstream binary method. Verify with which curl. If it is missing, install it first: sudo apt install curl
  • Architecture awareness: Know whether your system is x86-64 (x86_64) or ARM64 (aarch64). Run uname -m to check. Downloading the wrong binary for your architecture is the single most common upstream installation failure.

Understanding the Two Installation Methods

Ubuntu 26.04 gives you two ways to install 7-Zip, and they are not equivalent. Choosing the wrong one for your use case creates maintenance headaches later.

Method Package / Source Command Auto-Updates Best For
APT (Ubuntu repos) Universe repository 7z Yes, via apt upgrade Most users, servers, automation scripts
Official Upstream Binary 7-zip.org 7zz (double z) Manual reinstall Latest features, newest RAR5/ZSTD support

The critical difference is the command name. The APT method installs 7z (single z). The upstream binary installs 7zz (double z). These commands are not interchangeable in shell scripts or cron jobs. A script written for 7z will break silently on a system that only has 7zz, and vice versa. Pick one method, document it, and use it consistently across your infrastructure.

For servers and automated backup pipelines, use APT. It handles security patches automatically through Ubuntu’s update channels, which means one less thing to monitor. For development workstations where you want access to the absolute latest LZMA2 improvements or newer format support, the upstream binary is the right call.

Step 1: Update Your System Before Installing Anything

Running a system update before installing new software is not optional housekeeping. It is a real dependency safeguard.

WHY this step matters: APT stores a local cache of repository metadata. That cache can be days or weeks old on a freshly deployed server. If the metadata is stale, APT might try to download a package version that has already been superseded on the remote repository, causing a hash mismatch error that looks like a network failure. Updating first also ensures any pending security patches are applied before you add new software on top of a potentially vulnerable base system.

sudo apt update && sudo apt upgrade

Expected output (abbreviated):

Hit:1 http://archive.ubuntu.com/ubuntu plucky InRelease
Hit:2 http://archive.ubuntu.com/ubuntu plucky-updates InRelease
...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

If apt upgrade shows packages to update, let it run to completion before moving on.

Step 2: Install 7-Zip via APT (Recommended Method)

This is the right method for the vast majority of users. It takes two commands, provides automatic security updates, and integrates cleanly with the Ubuntu desktop environment.

Install the Package

sudo apt install 7zip

WHY 7zip and not p7zip-full? Starting with Ubuntu 24.04, Canonical replaced the p7zip-full package with the official 7zip package from the upstream 7-Zip project. On Ubuntu 26.04, p7zip-full still exists as a transitional metapackage that pulls in 7zip automatically, but calling it directly by its transitional name adds unnecessary indirection. Always use 7zip on Ubuntu 24.04 and newer for clarity in deployment scripts and documentation.

Expected output:

Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  7zip
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Unpacking 7zip ...
Setting up 7zip ...

Verify the Installation

7z

WHY verify explicitly? A successful apt install exit code of 0 confirms the package was placed on disk. It does not confirm the binary landed in your $PATH and is executable. Running 7z directly tests the full chain: disk presence, PATH resolution, and binary execution. This is the verification pattern you want in CI/CD scripts because it catches edge cases that a package manager exit code misses.

Expected output:

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>...]

Check the Installed Package Metadata

apt show 7zip

WHY check package metadata? This command reveals the installed version number, the upstream source URL, and the package maintainer. On a production server, this is the information you need when a CVE is disclosed against a specific 7-Zip version. You can confirm within seconds whether your system runs the affected version without guessing.

Expected output (abbreviated):

Package: 7zip
Version: 23.01+dfsg-5
Maintainer: Ubuntu Developers
Section: universe/utils

Step 3: Install the Official Upstream Binary (Advanced Method)

Use this method if you specifically need the latest upstream features, including improvements to LZMA2 performance or support for newer archive formats added after Ubuntu froze its package versions.

Verify Your System Architecture

uname -m

WHY check architecture before downloading? Downloading the x86-64 binary onto an ARM64 machine produces an Exec format error that looks identical to a corrupted download. Checking architecture first costs two seconds and prevents one of the most confusing installation failures a new Linux user can encounter.

Expected output on most desktops and servers:

x86_64

ARM64 output: aarch64. If you see aarch64, replace x64 with arm64 in all download commands below.

Download the Latest 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)"

WHY use this auto-detecting command instead of a hardcoded URL? A hardcoded URL like 7z2301-linux-x64.tar.xz becomes wrong the moment a new release ships. If you use a hardcoded URL in an Ansible role or a server provisioning script, it silently installs an outdated binary every time you run it, without any error. This two-step curl command parses the official download page, extracts the current filename using a regular expression, and downloads exactly that file. It stays correct across releases without any manual updates.

Verify the Download Checksum

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

WHY verify the SHA-256 hash? This step is not paranoia. On any publicly routed network, a man-in-the-middle can return a modified binary that passes all HTTP-level checks but contains a backdoor or crypto-miner. Comparing your downloaded file’s checksum against the value published at 7-zip.org takes fifteen seconds and gives you cryptographic proof the file is authentic and unmodified. For a binary you are about to install with root privileges, that verification is non-negotiable.

Compare your output against the checksum listed on the 7-zip.org download page for your specific release. They must match character for character.

Extract, Test, and Install

mkdir -p ~/7zip-install
tar xf ~/Downloads/7z*-linux-x64.tar.xz -C ~/7zip-install
~/7zip-install/7zz

WHY test the binary before installing it system-wide? Running the binary from the extraction directory is a dry-run gate. If it fails here due to a wrong architecture, a corrupted archive, or a missing glibc dependency, you catch the problem before the binary pollutes your system $PATH with a broken executable. This is standard practice in production server provisioning.

Expected output:

7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03

Once the binary runs correctly from the extraction directory, install it system-wide:

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

WHY /usr/local/bin and not /usr/bin? The Linux Filesystem Hierarchy Standard (FHS) reserves /usr/bin for packages managed by the system package manager. Manually placed binaries go in /usr/local/bin, which also appears earlier in the default $PATH order than /usr/bin. This means your manually installed 7zz takes priority over any system-managed file at the same path, and APT will never overwrite it during a routine apt upgrade run.

The -m 755 flag sets read and execute permissions for the owner, group, and others. Without the execute bit, the shell cannot run the binary even after finding it in $PATH.

Confirm System-Wide Availability

which 7zz
7zz 2>&1 | head -2

Expected output:

/usr/local/bin/7zz
7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03

WHY which and not just ls? The which command queries your shell’s $PATH resolution chain and returns the exact binary your shell will execute when you type 7zz. An ls /usr/local/bin/7zz only confirms the file exists at that path. On systems with modified $PATH variables or shell aliases, those two checks can return different results.

Step 4: Core 7-Zip Commands You Will Actually Use

With 7-Zip installed, here are the operations that cover 90 percent of real-world use cases. Substitute 7z or 7zz depending on which method you used to install.

Create a Compressed Archive

7z a archive.7z /path/to/files/

For maximum compression on large files or log directories:

7z a -mx=9 /backups/nginx-$(date +%Y%m%d).7z /etc/nginx/

WHY -mx=9? Compression level 9 activates Ultra mode in LZMA2. On configuration files and log data, this typically produces archives 60 to 70 percent smaller than the default level. For automated daily backups sent to S3 or similar object storage, that size reduction directly cuts storage costs and upload time. The tradeoff is higher CPU usage during compression. For a backup script that runs at 2 AM, that tradeoff is almost always worth it.

Extract an Archive

7z x archive.7z

To extract to a specific directory:

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

WHY no space between -o and the path? This is a 7-Zip-specific syntax quirk. Unlike most Linux tools where flags and values are space-separated, 7-Zip’s -o flag requires the path to be attached directly. 7z x archive.7z -o /tmp/ will fail or extract to the wrong location. This catches users coming from tar or unzip every time.

Test Archive Integrity

7z t archive.7z

Run this before relying on any archive for a critical restore. Expected output on a healthy archive:

Everything is Ok

List Archive Contents

7z l archive.7z

This lets you inspect what is inside an archive before extracting, which is a good habit on any file received from an external source.

Quick Command Reference Table

Operation Command Key Flag
Create archive 7z a archive.7z files/ -mx=9 for max compression
Extract with paths 7z x archive.7z -o/path for target directory
Extract flat (no directories) 7z e archive.7z -o/path for target directory
List contents 7z l archive.7z
Test integrity 7z t archive.7z
Update archive 7z u archive.7z newfile.txt
Delete from archive 7z d archive.7z oldfile.txt

Step 5: Keep 7-Zip Updated on Ubuntu 26.04 LTS

How you update 7-Zip depends entirely on how you installed it.

APT Method (Automatic)

sudo apt update && sudo apt upgrade

The APT installation gets security patches automatically through Ubuntu’s security channels as part of your normal system update routine. No extra maintenance steps required.

Upstream Binary Method (Manual)

The official binary has no automatic update mechanism. You must manually reinstall when a new version ships. Create an update script to make this repeatable:

#!/bin/bash
set -e
rm -f ~/Downloads/7z*-linux-x64.tar.xz
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)"
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
echo "Updated to:"
7zz 2>&1 | head -1

Save this as update-7zip.sh, make it executable with chmod +x update-7zip.sh, and run it whenever a new upstream release appears. The set -e flag stops the script immediately if any command fails, preventing a broken binary from replacing your working one.

Step 6: Configure 7-Zip on Ubuntu 26.04 for Automated Backup Workflows

Once 7-Zip is installed, you can integrate it into your Linux server tutorial automation stack. A practical starting point is a cron-based backup script.

Create a Backup Script

nano ~/scripts/daily-backup.sh

Paste the following:

#!/bin/bash
BACKUP_DIR="/backups"
SOURCE_DIR="/var/www/html"
DATE=$(date +%Y%m%d-%H%M%S)
ARCHIVE="${BACKUP_DIR}/web-backup-${DATE}.7z"

mkdir -p "$BACKUP_DIR"
7z a -mx=5 "$ARCHIVE" "$SOURCE_DIR"

# Keep only the last 7 backups
ls -tp "${BACKUP_DIR}"/web-backup-*.7z | grep -v '/$' | tail -n +8 | xargs -I {} rm -- {}

echo "Backup complete: $ARCHIVE"

Make it executable and schedule it:

chmod +x ~/scripts/daily-backup.sh
crontab -e

Add this line to run the backup at 2 AM daily:

0 2 * * * /bin/bash ~/scripts/daily-backup.sh >> /var/log/daily-backup.log 2>&1

WHY -mx=5 instead of -mx=9 in an automated script? Ultra compression at level 9 uses significantly more CPU and RAM, which can interfere with production workloads running on the same server. Level 5 (the default) offers a good balance between compression ratio and resource usage for scheduled jobs. Reserve -mx=9 for one-time, high-value archives where size matters more than speed.

Troubleshooting Common 7-Zip Issues on Ubuntu 26.04

Error: command not found After APT Installation

Symptom:

bash: 7z: command not found

Why it happens: /usr/bin is missing from the shell’s $PATH, or the shell session predates the installation.

Fix:

echo $PATH

Confirm /usr/bin appears in the output. If it does not:

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

Then confirm with which 7z.

Error: Exec format error with Upstream Binary

Symptom:

bash: /usr/local/bin/7zz: cannot execute binary file: Exec format error

Why it happens: You downloaded the x86-64 binary on an ARM64 machine, or the reverse.

Fix:

uname -m
sudo rm /usr/local/bin/7zz

Re-download using the correct architecture variant (replace x64 with arm64 in the curl command for ARM64 systems) and reinstall.

Error: Old Version Persists After Upgrade

Symptom: 7zz still reports the old version number immediately after reinstalling.

Why it happens: Bash caches binary locations in a hash table for performance. The cache is not automatically cleared when a binary at the same path is replaced.

Fix:

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

hash -r clears the shell’s command hash table for the current session. New terminal sessions will not have this problem.

Error: Can Not Open the File as Archive

Symptom: 7-Zip fails during extraction with a message like “Can not open the file as archive.”

Why it happens: The downloaded .tar.xz archive is corrupted, usually from a partial or interrupted download.

Fix:

rm -f ~/Downloads/7z*-linux-x64.tar.xz
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)"
sha256sum 7z*-linux-x64.tar.xz

Verify the checksum against 7-zip.org before re-attempting extraction.

Error: Permission Denied When Running 7zz

Symptom:

bash: /usr/local/bin/7zz: Permission denied

Why it happens: The install command did not set the executable bit correctly.

Fix:

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

Then verify: ls -l /usr/local/bin/7zz should show -rwxr-xr-x in the permissions column.

How to Uninstall 7-Zip from Ubuntu 26.04

Remove the APT Package

sudo apt remove 7zip
sudo apt autoremove

WHY run autoremove separately? apt remove removes only the 7zip package itself. Any dependencies APT pulled in automatically during installation remain on disk as orphans. autoremove cleans those up, which prevents gradual storage bloat on servers that go through many install and remove cycles over time.

Remove the Upstream Binary

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

Verify complete removal:

which 7zz && echo "still installed" || echo "removed"

Both paths returning removed confirms the binary is fully gone.

Congratulations! You have successfully installed 7-Zip. Thanks for using this tutorial for installing the 7-Zip compression of files and directories on Ubuntu 26.04 LTS (Resolute Raccoon) system. For additional help or useful information, we recommend you check the official 7-Zip website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts