How to Install 7-Zip on Ubuntu 26.04, 24.04 and 22.04

Install 7-Zip on Ubuntu 26.04, 24.04 and 22.04 using the upstream binary. Get latest features, security updates, high compression.

Last updatedAuthorJoshua JamesRead time8 minGuide typeUbuntu

Archive work on Ubuntu gets confusing because 7z, 7zz, 7zip, and p7zip-full do not mean the same thing on every supported LTS release. To install 7-Zip on Ubuntu, start with the Ubuntu package when you want a distro-managed command, then use the official 7zz binary only when you need the newest upstream release or a no-sudo workaround.

Ubuntu 26.04 LTS (Resolute Raccoon) and 24.04 LTS (Noble Numbat) use the 7zip package for the 7z command. Ubuntu 22.04 LTS (Jammy Jellyfish) still uses p7zip-full when you need the legacy 7z command, while its separate 7zip package installs 7zz. That distinction matters for package commands, RAR extraction, direct downloads, and managed shells such as Google Cloud Shell.

Install 7-Zip on Ubuntu

Use APT for the normal system-managed install path. It keeps 7-Zip inside Ubuntu’s package database, handles updates through apt upgrade, and avoids manually replacing files under /usr/local/bin.

Update Ubuntu Packages Before Installing 7-Zip

Refresh the package index before installing so APT sees the current package candidate for your release:

sudo apt update && sudo apt upgrade

These commands use sudo for tasks 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.

Quick 7-Zip APT Commands for Ubuntu

On Ubuntu 26.04 and 24.04, install the current 7zip package:

sudo apt install 7zip

On Ubuntu 22.04, install p7zip-full if you want the traditional 7z command used by older tutorials and desktop archive tools:

sudo apt install p7zip-full

There is no separate Ubuntu package named 7z. The command comes from 7zip on Ubuntu 26.04 and 24.04, and from p7zip-full on Ubuntu 22.04.

The APT packages used here are in Ubuntu’s universe component. Most desktop installs already have Universe enabled, but customized or minimal systems may need the Ubuntu Universe and Multiverse repository guide before APT can locate the package.

Compare Ubuntu 7-Zip Packages

The package name changed across supported Ubuntu releases, so use the release-aware table before copying commands between machines:

Ubuntu ReleaseInstall PackageMain CommandAPT CandidateNotes
Ubuntu 26.04 (Resolute)7zip7z26.00+dfsg-1p7zip-full has no candidate in the 26.04 repositories.
Ubuntu 24.04 (Noble)7zip7z23.01+dfsg-11p7zip-full is only a transitional package that depends on 7zip.
Ubuntu 22.04 (Jammy)p7zip-full7z16.02+dfsg-8The optional 7zip package is 21.07+dfsg-4 and installs 7zz, not 7z.

For normal APT usage, avoid installing both package families on Ubuntu 22.04 unless you specifically need to compare 7z and 7zz. On Ubuntu 24.04 and newer, 7zip replaces the old p7zip package names.

Verify the APT 7-Zip Install

Check the command that matches your package method. On Ubuntu 26.04 and 24.04, use 7z from the 7zip package:

7z | sed -n '/^7-Zip/p' | head -n 1
7-Zip 26.00 (x64) : Copyright (c) 1999-2026 Igor Pavlov : 2026-02-12

Ubuntu 24.04 shows 7-Zip 23.01 from the same command. On Ubuntu 22.04 with p7zip-full, the first version line shows 7-Zip [64] 16.02.

Install Official 7-Zip 7zz Binary on Ubuntu

The official 7-Zip Linux download is useful when you need the newest upstream 7zz binary or when you cannot install APT packages system-wide. The Linux assets are versioned .tar.xz archives, named by release and architecture; upstream does not publish a Linux .deb or Linux .zip installer for this path.

This method can coexist with the APT package because it installs 7zz, while the normal Ubuntu package path usually exposes 7z. Install curl first if your Ubuntu system does not already include it:

sudo apt install curl

Detect the Correct 7-Zip Linux Architecture

Run this architecture mapping before the download commands. Keep the same terminal open for the next steps because they reuse SEVENZIP_ARCH.

case "$(uname -m)" in
    x86_64) SEVENZIP_ARCH="x64" ;;
    aarch64) SEVENZIP_ARCH="arm64" ;;
    armv7l|armv6l) SEVENZIP_ARCH="arm" ;;
    i386|i686) SEVENZIP_ARCH="x86" ;;
    *) echo "Unsupported architecture: $(uname -m)"; exit 1 ;;
esac

printf '7-Zip Linux architecture: %s\n' "$SEVENZIP_ARCH"
7-Zip Linux architecture: x64

Resolve the Official 7-Zip Download URL

Resolve the current official tarball URL from the 7-Zip download page. The command uses grep pattern matching to select the matching Linux archive, and it accepts both the current GitHub-hosted release links and older relative a/ links from 7-Zip.org.

DOWNLOAD_URL=$(curl -fsSL https://www.7-zip.org/download.html | grep -Eo "(https://github.com/ip7z/7zip/releases/download/[0-9.]+/7z[0-9]+-linux-${SEVENZIP_ARCH}\.tar\.xz|a/7z[0-9]+-linux-${SEVENZIP_ARCH}\.tar\.xz)" | head -n 1 || true)

if [ -z "$DOWNLOAD_URL" ]; then
    echo "No 7-Zip Linux ${SEVENZIP_ARCH} tarball found"
    exit 1
fi

case "$DOWNLOAD_URL" in
    a/*) DOWNLOAD_URL="https://www.7-zip.org/$DOWNLOAD_URL" ;;
esac

printf '%s\n' "$DOWNLOAD_URL"

A successful run prints the current official tarball URL for your architecture. The exact version changes when upstream releases a new build, so check that the URL comes from the official 7-Zip download page and ends in linux-${SEVENZIP_ARCH}.tar.xz.

Download and Test Official 7zz

Download the resolved archive, extract it, and run the bundled 7zz binary before installing it system-wide:

mkdir -p "$HOME/Downloads" "$HOME/7zip-install"
cd "$HOME/Downloads"

ARCHIVE_NAME="${DOWNLOAD_URL##*/}"
rm -f "$ARCHIVE_NAME"
curl -fSLO "$DOWNLOAD_URL"
tar xf "$ARCHIVE_NAME" -C "$HOME/7zip-install"

"$HOME/7zip-install/7zz" | sed -n '/^7-Zip/p' | head -n 1

The first output line should begin with 7-Zip (z) and show the current upstream version for your architecture.

Verify the Official 7-Zip Checksum

For security-sensitive systems, compare the local checksum with the SHA-256 value shown beside the matching file on the official 7-Zip download page:

sha256sum "$ARCHIVE_NAME"

The checksum changes with each release, so do not reuse an older value from another tutorial. Match the full hash character for character before installing the binary on systems where supply-chain verification matters.

Install Official 7zz System-Wide

Install the tested binary under /usr/local/bin. The install command copies the file and sets executable permissions in one step:

sudo install -m 755 "$HOME/7zip-install/7zz" /usr/local/bin/7zz
command -v 7zz
/usr/local/bin/7zz

Run a final version check after installation:

7zz | sed -n '/^7-Zip/p' | head -n 1

If the first line starts with 7-Zip (z), the upstream binary is ready.

Use 7zz Without Sudo or in Google Cloud Shell

Google Cloud Shell and other managed shells are not always normal Ubuntu hosts. Commands such as sudo apt install p7zip-full or sudo apt install 7zip work only when that environment allows package installation.

Without sudo access, skip the system-wide /usr/local/bin install step and run the extracted upstream binary from your home directory instead:

"$HOME/7zip-install/7zz" | sed -n '/^7-Zip/p' | head -n 1

This does not add a global 7zz command, but it gives you a working 7-Zip binary when a managed shell blocks APT or root-owned paths.

Update the Official 7-Zip Binary

APT-installed packages update with the rest of Ubuntu. The official upstream binary is manual, so create a small updater if you want to refresh /usr/local/bin/7zz later without repeating every download step.

sudo tee /usr/local/bin/update-7zip > /dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

download_page="https://www.7-zip.org/download.html"
cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/7zip-updater"
install_dir="/usr/local/bin"

case "$(uname -m)" in
    x86_64) arch="x64" ;;
    aarch64) arch="arm64" ;;
    armv7l|armv6l) arch="arm" ;;
    i386|i686) arch="x86" ;;
    *) echo "Unsupported architecture: $(uname -m)" >&2; exit 1 ;;
esac

rm -rf "$cache_dir/extract"
mkdir -p "$cache_dir/extract"

url="$(curl -fsSL "$download_page" | grep -Eo "(https://github.com/ip7z/7zip/releases/download/[0-9.]+/7z[0-9]+-linux-${arch}\.tar\.xz|a/7z[0-9]+-linux-${arch}\.tar\.xz)" | head -n 1 || true)"
if [[ -z "$url" ]]; then
    echo "No 7-Zip Linux $arch tarball found on $download_page" >&2
    exit 1
fi

if [[ "$url" == a/* ]]; then
    url="https://www.7-zip.org/$url"
fi

archive="$cache_dir/${url##*/}"
echo "Downloading $url"
curl -fSL -o "$archive" "$url"
tar xf "$archive" -C "$cache_dir/extract"
sudo install -m 755 "$cache_dir/extract/7zz" "$install_dir/7zz"
"$install_dir/7zz" | sed -n '/^7-Zip/p' | head -n 1
EOF

sudo chmod 755 /usr/local/bin/update-7zip

Run the helper whenever you want to refresh the upstream binary:

update-7zip

The helper prints the resolved official URL and the first 7zz version line after installation. It uses a cache directory under ~/.cache instead of /tmp, which avoids quota issues on systems with small temporary filesystems.

Use 7-Zip Commands on Ubuntu

Understand 7z vs 7zz Command Names

The 7z command is the normal Ubuntu package command for most readers. The 7zz command is the newer upstream-style binary name, used by the official Linux tarball and by Ubuntu 22.04’s optional 7zip package.

The examples below use 7z because that matches the recommended APT path. If you installed the official binary, replace 7z with 7zz.

SubcommandActionExample
aCreate a new archive or add files7z a archive.7z files/
xExtract with full directory paths7z x archive.7z
eExtract without directory paths7z e archive.7z
lList archive contents7z l archive.7z
uUpdate an existing archive7z u archive.7z newfile.txt
tTest archive integrity7z t archive.7z
dDelete files from an archive7z d archive.7z oldfile.txt

Create a 7-Zip Archive

Create a new archive with the a subcommand. The archive format follows the extension you choose:

7z a archive.7z file.txt

Add a directory the same way:

7z a project-backup.7z "$HOME/Documents/project/"

For maximum 7z compression, add -mx=9. This can take noticeably longer on large files:

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

Extract an Archive with 7-Zip

Use x when you want 7-Zip to preserve the original directory structure:

7z x archive.7z

Extract into a specific directory with -o. 7-Zip expects no space between -o and the output path:

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

For ordinary ZIP files, the distro-agnostic unzip command examples can be simpler. For .tar.gz, .tgz, or .tar.xz files, see the guide on extracting tar.gz and tar.xz archives in Linux.

List Archive Contents

Preview archive contents before extracting with the l subcommand:

7z l archive.7z

The listing shows filenames, sizes, compression information, and timestamps. Use it when you want to check an archive before unpacking it into the current directory.

Update an Existing Archive

Add new files or replace changed files inside an archive with u:

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

Files that have not changed remain untouched. This is useful for small backup archives where recreating the whole file would be slower.

Test Archive Integrity

Test important archives after downloads or transfers before you trust them for backups:

7z t archive.7z
Everything is Ok

If 7-Zip reports CRC errors, unexpected end-of-data messages, or another failure, download or copy the archive again before extracting it.

Extract RAR Files with 7-Zip

7-Zip can extract RAR and RAR5 archives, but it cannot create RAR archives because the RAR compression format is proprietary. Use x the same way you would for a 7z or ZIP file:

7z x archive.rar

On Ubuntu 22.04, prefer p7zip-full for the 7z command when RAR extraction matters. Ubuntu 22.04’s separate 7zip package installs 7zz 21.07, which can fail on newer RAR archives; the official upstream 7zz binary or the p7zip-full 7z command is the safer choice for that workflow. For dedicated RAR tooling, use the same-distro guide to install unrar on Ubuntu.

Troubleshoot 7-Zip on Ubuntu

Fix 7z Command Not Found

If 7z is missing, install the package that owns it for your Ubuntu release:

command -v 7z

On Ubuntu 26.04 and 24.04, fix a missing 7z command with:

sudo apt install 7zip

On Ubuntu 22.04, install the legacy package instead:

sudo apt install p7zip-full

Fix 7zz Command Not Found

If you installed the official binary and 7zz is still missing, check the system-wide path first:

test -x /usr/local/bin/7zz && echo "/usr/local/bin/7zz is executable"
echo "$PATH" | tr ':' '\n' | grep -Fx /usr/local/bin
/usr/local/bin/7zz is executable
/usr/local/bin

If the file exists but the shell still cannot find it in the current terminal, clear the shell command cache and try again:

hash -r
command -v 7zz

Fix Unsupported Architecture Errors

If the official binary was downloaded for the wrong CPU type, Bash may show this error:

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

Check the machine architecture and repeat the official download flow with the matching asset:

uname -m
x86_64

Systems showing x86_64 need the linux-x64 tarball. Systems showing aarch64 need linux-arm64. Remove the wrong system-wide binary before reinstalling:

sudo rm -f /usr/local/bin/7zz

Fix Corrupted 7-Zip Downloads

If tar or 7zz reports that the downloaded file is not a valid archive, delete the file and rerun the official download command. If you opened a new terminal, repeat the architecture and URL-resolution steps first so SEVENZIP_ARCH and DOWNLOAD_URL are set again.

cd "$HOME/Downloads"
rm -f 7z*-linux-"$SEVENZIP_ARCH".tar.xz
curl -fSLO "$DOWNLOAD_URL"

Then compare the SHA-256 checksum with the official value before extracting again.

Remove 7-Zip from Ubuntu

Removal depends on the install method. Remove only the package or binary you actually installed.

Remove APT 7-Zip Packages

On Ubuntu 26.04 and 24.04, remove the 7zip package:

sudo apt remove 7zip

On Ubuntu 22.04, remove p7zip-full if that was the package you installed:

sudo apt remove p7zip-full

Preview dependency cleanup before running a real autoremove, especially on reused desktops where unrelated packages may already be marked automatic:

sudo apt autoremove --dry-run

If the preview lists only packages you expect to remove, run the cleanup interactively:

sudo apt autoremove

Remove Official 7zz Binary and Updater

For the manually installed official binary, remove the launcher, optional updater, extraction directory, and updater cache:

sudo rm -f /usr/local/bin/7zz /usr/local/bin/update-7zip
rm -rf "$HOME/7zip-install" "$HOME/.cache/7zip-updater"
rm -f "$HOME"/Downloads/7z*-linux-*.tar.xz

Clear the shell cache, then check whether the official 7zz binary still resolves:

hash -r
command -v 7zz || echo "7zz removed"
7zz removed

The 7z command can still exist after this cleanup if you also installed the APT package. Remove the APT package separately when you want 7-Zip gone completely.

Conclusion

7-Zip is available on Ubuntu through APT for normal system-managed use, while upstream 7zz covers newer release or no-sudo cases. Keep the 7z and 7zz distinction in mind when sharing commands. For adjacent archive work, the guides for extracting tar.gz and tar.xz archives, unzip examples, and installing unrar on Ubuntu cover common formats.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show our tutorials more often in Top Stories and mark them as preferred in AI Mode and AI Overviews when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee

1 thought on “How to Install 7-Zip on Ubuntu 26.04, 24.04 and 22.04”

Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Add to the discussion

Questions, fixes, command output, and version notes help keep this guide current.

Verify before posting: