How to Install 7-Zip on Debian

7-Zip is a command-line archive utility for creating and extracting 7z, zip, tar, gzip, and ISO files, with optional AES-256 encryption for protected archives. Whether you need smaller backups, quick extraction of downloads, or encrypted archives, this guide installs the correct package for Debian 11, 12, or 13, verifies the binary you should use, and provides practical command examples.

Understand 7-Zip Packaging on Debian

Debian’s 7-Zip packaging and supported formats differ between releases. Understanding these differences ensures you install the correct package and use the right command for your version:

  • Debian 13 (Trixie): Install the 7zip package, which provides the 7z command. This is the official 7-Zip from Igor Pavlov and includes RAR/RAR5 extraction.
  • Debian 12 (Bookworm): Install the 7zip package, but the command is 7zz (not 7z). This is the official 7-Zip, but the Debian build does not include RAR/RAR5 extraction.
  • Debian 11 (Bullseye): The 7zip package does not exist. Instead, install p7zip-full, which provides the 7z command. This is the p7zip fork, not the official 7-Zip, and it includes RAR/RAR5 extraction.

All packages are available in Debian’s default main repository – no additional repositories are required.

If you need RAR extraction on Debian 12, use the manual binary method below or see our Debian unrar installation guide for dedicated RAR tools.

Choose Your 7-Zip Installation Method

Debian offers two ways to install 7-Zip: APT (Advanced Package Tool, Debian’s standard package manager) or a manual binary download from the official GitHub releases. On one hand, the APT method provides automatic updates and integrates with your system’s package management. On the other hand, the manual method lets you install the latest upstream version immediately.

MethodChannelVersionUpdatesBest For
APT Package ManagerDebian ReposStable per releaseAutomatic via APT updatesMost users who want simple maintenance
Manual BinaryGitHub ReleasesLatest upstreamManual re-downloadUsers who need newest features immediately

For most users, the APT method is recommended because all supported Debian versions include 7-Zip (or p7zip) in their default repositories with automatic security updates and no manual maintenance required. Only use the manual binary method if you specifically need a newer version than what Debian provides.

Update Debian Before Installation

Before installing any software, refresh your package lists so APT can see the latest versions available for your release:

sudo apt update

Optional: run sudo apt upgrade if you want to apply all pending updates before installing 7-Zip.

Install 7-Zip with APT (Recommended)

Follow the instructions for your specific Debian version. The package name and command differ between releases.

Debian 13 (Trixie)

Debian 13 includes the official 7-Zip package with the familiar 7z command:

sudo apt install 7zip

Verify the installation:

7z

Example output (truncated):

7-Zip 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

The package provides 7z (full-featured), 7za (standalone), and 7zr (reduced version for .7z files only). For most tasks, use 7z.

Debian 12 (Bookworm)

Debian 12 includes the official 7-Zip package, but the binary is named 7zz instead of 7z:

sudo apt install 7zip

Verify the installation using the correct command:

7zz

Example output (truncated):

7-Zip (z) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
Usage: 7zz <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

Remember to use 7zz for all commands in the examples below if you are on Debian 12.

Debian 11 (Bullseye)

Debian 11 does not have the 7zip package. Instead, install p7zip-full, which is a community fork that provides compatible functionality:

sudo apt install p7zip-full

Verify the installation:

7z

Example output (truncated):

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]

The version line and extra details vary by Debian release and system hardware, so the output above is trimmed to show the format.

The p7zip package provides 7z and 7za commands that work identically to the official 7-Zip for standard operations.

Install 7-Zip from Official Binary (Alternative)

If you need the latest version or want 7-Zip without root access, download the official binary directly from the 7-Zip GitHub releases page. This is also the simplest way to get RAR/RAR5 extraction on Debian 12. The upstream tarball includes the 7zz binary (and 7zzs), always uses the 7zz name, and includes RAR/RAR5 extraction. Because this method bypasses APT, you update it by downloading a newer release.

Step 1: Install Prerequisite Tools (Manual Method)

This method uses curl to query GitHub, wget to download the tarball, and xz-utils to extract it:

sudo apt install ca-certificates curl wget xz-utils

Step 2: Check Your Architecture

dpkg --print-architecture

Expected output for 64-bit Intel/AMD systems:

amd64

Other possible outputs include arm64 for ARM-based systems or i386 for 32-bit systems. Use the matching linux-* filename from the releases page in the download and extraction commands below.

Step 3: Download the Latest Release

curl -s https://api.github.com/repos/ip7z/7zip/releases/latest | grep -oP '"browser_download_url": "\K[^"]+linux-x64[^"]+' | xargs wget

This command automatically fetches the latest version. Here is how it works:

  • curl -s: Silently fetches release metadata from GitHub’s API
  • grep -oP: Extracts the x64 Linux download URL using regex
  • xargs wget: Downloads the tarball using the extracted URL

If you are not on amd64, replace linux-x64 in both the download and extraction commands with the exact filename from the releases page (for example, linux-arm64 or linux-x86). If the automated download fails, visit the 7-Zip releases page manually and download the appropriate archive for your architecture.

Next, extract the downloaded archive (use the same linux-* suffix you downloaded):

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

The archive extracts 7zz, 7zzs, and documentation files into the current directory. You only need 7zz for normal CLI use. You have two installation options depending on whether you have root access.

Option A: System-Wide Installation (Requires sudo)

Move the binary to a system-wide location so all users can access it:

sudo mv 7zz /usr/local/bin/

Verify the installation:

7zz

Example output (truncated):

7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
Usage: 7zz <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

Option B: User-Local Installation (No sudo Required)

If you do not have root access or prefer to keep the binary in your home directory, install it to ~/.local/bin:

mkdir -p ~/.local/bin && mv 7zz ~/.local/bin/

Ensure ~/.local/bin is in your PATH. Check with:

echo $PATH | grep -o '\.local/bin'

Expected output when it is present:

.local/bin

If this returns nothing, add it to your shell configuration:

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

Alternatively, open a new terminal window so the updated PATH is loaded automatically.

Verify the installation:

7zz

Example output (truncated):

7-Zip (z) 25.01 (x64) : Copyright (c) 1999-2025 Igor Pavlov : 2025-08-03
Usage: 7zz <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

The manual binary is always named 7zz. The APT package provides 7z on Debian 11 and 13, but 7zz on Debian 12. Command syntax is the same, but format support can differ between packages.

Update the Manual 7-Zip Binary

Because the manual install bypasses APT, you update it by downloading the latest release and replacing the 7zz binary. The script below checks your current version, compares it to the latest GitHub release, and updates only when needed.

Save this as ~/update-7zz.sh:

cat <<'EOF' > ~/update-7zz.sh
#!/usr/bin/env bash
set -euo pipefail

require_cmd() {
  command -v "$1" >/dev/null 2>&1 || { echo "Error: $1 is required."; exit 1; }
}

for cmd in curl tar awk dpkg mktemp install; do
  require_cmd "$cmd"
done

if ! command -v 7zz >/dev/null 2>&1; then
  echo "Error: 7zz is not in PATH. This script updates the manual 7-Zip binary only."
  echo "If you installed via APT, run: sudo apt install --only-upgrade 7zip"
  exit 1
fi

INSTALL_PATH="$(command -v 7zz)"
if [ "$INSTALL_PATH" = "/usr/bin/7zz" ]; then
  echo "Detected APT-managed 7zz at /usr/bin/7zz."
  echo "Update it with: sudo apt install --only-upgrade 7zip"
  exit 0
fi

ARCH="$(dpkg --print-architecture)"
case "$ARCH" in
  amd64) ARCH_TAG="linux-x64" ;;
  arm64) ARCH_TAG="linux-arm64" ;;
  armhf) ARCH_TAG="linux-arm" ;;
  i386) ARCH_TAG="linux-x86" ;;
  *) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac

API_URL="https://api.github.com/repos/ip7z/7zip/releases/latest"
RELEASE_JSON="$(curl -fsSL "$API_URL")"
LATEST_TAG="$(printf '%s' "$RELEASE_JSON" | awk -F'\"' '/\"tag_name\":/ {print $4; exit}')"
LATEST_URL="$(printf '%s' "$RELEASE_JSON" | awk -F'\"' -v arch="$ARCH_TAG" '/browser_download_url/ && $0 ~ arch {print $4; exit}')"

if [ -z "$LATEST_TAG" ] || [ -z "$LATEST_URL" ]; then
  echo "Error: Could not determine the latest release information from GitHub."
  exit 1
fi

CURRENT_VERSION="$(7zz -h | awk 'NF {print $3; exit}')"
if [ -z "$CURRENT_VERSION" ]; then
  CURRENT_VERSION="unknown"
fi

echo "Detected install: $INSTALL_PATH"
echo "Architecture: $ARCH ($ARCH_TAG)"
echo "Current version: $CURRENT_VERSION"
echo "Latest version: $LATEST_TAG"

if [ "$CURRENT_VERSION" = "$LATEST_TAG" ]; then
  echo "7-Zip is already up to date."
  exit 0
fi

echo "Updating 7-Zip from $CURRENT_VERSION to $LATEST_TAG..."
WORKDIR="$(mktemp -d)"
trap 'rm -rf "$WORKDIR"' EXIT

ARCHIVE="$WORKDIR/7z-${LATEST_TAG}-${ARCH_TAG}.tar.xz"
curl -fL --progress-bar "$LATEST_URL" -o "$ARCHIVE"
tar -xf "$ARCHIVE" -C "$WORKDIR"

if [ ! -x "$WORKDIR/7zz" ]; then
  echo "Error: 7zz not found in the downloaded archive."
  exit 1
fi

INSTALL_DIR="$(dirname "$INSTALL_PATH")"
if [ -w "$INSTALL_DIR" ]; then
  install -m 0755 "$WORKDIR/7zz" "$INSTALL_PATH"
elif [ "$(id -u)" -eq 0 ]; then
  install -m 0755 "$WORKDIR/7zz" "$INSTALL_PATH"
elif command -v sudo >/dev/null 2>&1; then
  sudo install -m 0755 "$WORKDIR/7zz" "$INSTALL_PATH"
else
  echo "Error: $INSTALL_DIR is not writable and sudo is not available."
  echo "Run this script as root or reinstall to ~/.local/bin."
  exit 1
fi

echo "Update complete."
7zz -h | awk 'NF {print; exit}'
EOF

Make it executable and run it:

chmod +x ~/update-7zz.sh
~/update-7zz.sh

Example output when you are already on the latest version:

Detected install: /usr/local/bin/7zz
Architecture: amd64 (linux-x64)
Current version: 25.01
Latest version: 25.01
7-Zip is already up to date.

Avoid automating this with cron. Download failures or permission prompts can leave a partial update, so run the script manually and review the output.

Manage Archives with 7-Zip Commands

After installing 7-Zip, you can compress, extract, and manage archives from the command line. The examples below use 7z. Substitute the correct binary name for your setup:

  • Debian 11 (APT): Use 7z
  • Debian 12 (APT): Use 7zz
  • Debian 13 (APT): Use 7z
  • Manual binary (any version): Use 7zz

All commands and switches work identically regardless of which binary you use, but format support differs by package (for example, Debian 12’s 7zz build does not include RAR/RAR5 extraction).

Create a Compressed Archive

Compress a file or directory into a .7z archive using the a (add) command:

7z a archive.7z file.txt

Example output (truncated; sizes vary):

Scanning the drive:
1 file, 5 bytes (1 KiB)

Creating archive: archive.7z

Add new data to archive: 1 file, 5 bytes (1 KiB)

Files read from disk: 1
Archive size: 131 bytes (1 KiB)
Everything is Ok

Similarly, to compress an entire directory including all subdirectories:

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

Extract an Archive

Extract all files from an archive to the current directory using the x command, which preserves directory structure:

7z x archive.7z

Example output (truncated; sizes vary):

Scanning the drive for archives:
1 file, 237 bytes (1 KiB)

Extracting archive: archive.7z

Everything is Ok

Folders: 1
Files: 3
Size:       32
Compressed: 237

Alternatively, to extract to a specific directory, use the -o switch (note there is no space between -o and the path):

7z x archive.7z -o/path/to/destination/

Instead of 7z x, use 7z e to extract all files into a flat directory without preserving folder structure. This is particularly useful when you only care about the files themselves, not their original locations.

List Archive Contents

View the contents of an archive without extracting using the l (list) command:

7z l archive.7z

Example output (truncated; dates and sizes vary):

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2025-12-27 08:29:10 D....            0            0  subdir
2025-12-27 08:29:10 ....A           13           34  file2.txt
2025-12-27 08:29:10 ....A            7               subdir/nested.txt
2025-12-27 08:29:10 ....A           12               test.txt
------------------- ----- ------------ ------------  ------------------------
2025-12-27 08:29:10                 32           34  3 files, 1 folders

As shown above, the output displays each file’s date, attributes, original size, compressed size, and path within the archive.

Update an Existing Archive

Add new files to an existing archive using the u (update) command. This adds new files and replaces existing files only if the source is newer:

7z u archive.7z newfile.txt

Conversely, to delete a file from an archive, use the d command:

7z d archive.7z oldfile.txt

Create an Encrypted Archive

Encrypt an archive with a password using AES-256 encryption:

7z a -p -mhe=on secure.7z sensitive-files/

Here, the -p flag prompts for a password, while -mhe=on encrypts file names in addition to content. For RAR extraction, note that Debian 12’s 7zz package does not include RAR/RAR5 support; use the manual binary method above or see our Debian unrar installation guide for dedicated RAR tools.

Test Archive Integrity

Before relying on an archive for backups or transfers, always verify its integrity using the t (test) command:

7z t archive.7z

Example output (truncated; sizes vary):

Scanning the drive for archives:
1 file, 237 bytes (1 KiB)

Testing archive: archive.7z

Everything is Ok

Folders: 1
Files: 3
Size:       32
Compressed: 237

In contrast, if corruption exists, 7-Zip reports which files failed the integrity check.

Control Compression Level

Adjust the compression level with -mx followed by a number from 0 (store only, no compression) to 9 (ultra compression). Higher levels compress better but take longer:

7z a -mx9 maximum.7z largefile.iso

Alternatively, for faster compression with slightly larger files, use -mx1:

7z a -mx1 fast.7z largefile.iso

Generally, the default level (-mx5) balances speed and compression for most use cases.

Create Split Archives for Large Files

When archiving files that exceed file size limits (such as email attachments or FAT32 partitions), split the archive into volumes with -v followed by the size:

7z a -v100m split-archive.7z large-backup/

As a result, this creates multiple files named split-archive.7z.001, split-archive.7z.002, and so on, each no larger than 100 MB. Common size suffixes include k (kilobytes), m (megabytes), and g (gigabytes).

Later, to extract a split archive, simply run the extraction command on the first volume:

7z x split-archive.7z.001

Exclude Files by Pattern

Exclude specific files or patterns from compression using -x. To exclude all .log files recursively:

7z a backup.7z project/ -xr!*.log

Here, the r modifier makes the exclusion recursive through subdirectories. Likewise, to exclude multiple patterns, simply repeat the switch:

7z a backup.7z project/ -xr!*.log -xr!*.tmp -xr!node_modules

Troubleshoot 7-Zip Issues

Use the same binary name you installed in the commands below (7z or 7zz).

Command Not Found After Manual Installation

If you see this error after manual installation:

bash: 7zz: command not found

The binary may not be in your PATH or was not moved correctly. Verify the binary exists:

ls -lh /usr/local/bin/7zz

If you installed to ~/.local/bin, check that location instead:

ls -lh ~/.local/bin/7zz

Example output (size and timestamp vary):

-rwxr-xr-x 1 root root 2.8M Aug  3 18:08 /usr/local/bin/7zz

If you see No such file or directory, repeat the move command with sudo:

sudo mv 7zz /usr/local/bin/

However, if the file exists but the command still fails, check that /usr/local/bin is in your PATH:

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

Expected output:

/usr/local/bin

If this returns nothing, then /usr/local/bin is not in your PATH. Consequently, either use the full path (/usr/local/bin/7zz) or add it to your shell configuration.

Architecture Mismatch Error

If you downloaded the wrong architecture (for example, x86 on an ARM system), you will see an error like:

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

Check your architecture and download the correct binary:

dpkg --print-architecture

Next, remove the incorrect binary and download the matching version:

sudo rm /usr/local/bin/7zz

Afterward, visit the releases page and download the correct archive for your architecture.

Permission Denied When Extracting

If extraction fails with this error:

ERROR: CFileOutStream::Create: Can not open output file: /opt/destination/file.txt
System ERROR: Permission denied

This means you are trying to extract to a directory you do not own. Instead, either extract to your home directory or use sudo:

sudo 7z x archive.7z -o/opt/destination/

If your user account lacks sudo privileges, see our guide on adding a user to sudoers on Debian.

Corrupted or Incomplete Archive

If extraction or testing fails with errors like these:

ERROR: CRC Failed : filename.txt
ERROR: Data Error in encrypted file. Wrong password?

First, test the archive integrity to confirm which files are affected:

7z t archive.7z

If multiple files fail, the archive may have been corrupted during download or transfer. In that case, re-download the file or request a fresh copy. For encrypted archives showing “Wrong password,” verify you are entering the exact password since passwords are case-sensitive.

Remove 7-Zip from Debian

If you no longer need 7-Zip, remove it based on how you installed it.

Remove APT Installation

For Debian 12 and 13, uninstall the 7zip package:

sudo apt remove --purge 7zip && sudo apt autoremove

For Debian 11, remove the p7zip-full package instead:

sudo apt remove --purge p7zip-full && sudo apt autoremove

If you also installed the manual binary, it will still be present in /usr/local/bin or ~/.local/bin until you remove it in the next section.

Verify the APT removal:

Debian 11 and 13:

7z
bash: 7z: command not found

Debian 12:

7zz
bash: 7zz: command not found

Remove Manual Binary Installation

Delete the binary based on where you installed it. For system-wide installation:

sudo rm /usr/local/bin/7zz

For user-local installation:

rm ~/.local/bin/7zz

Verify the binary is gone from the location you used:

ls -la /usr/local/bin/7zz
ls: cannot access '/usr/local/bin/7zz': No such file or directory
ls -la ~/.local/bin/7zz
ls: cannot access '/home/user/.local/bin/7zz': No such file or directory

If you added ~/.local/bin to your PATH, remove that line from ~/.bashrc or ~/.profile and open a new terminal session.

Clean up leftover files in the directory where you extracted 7-Zip: rm ~/7z*-linux-*.tar.xz ~/7zzs ~/readme.txt ~/License.txt ~/History.txt. Remove the MANUAL directory if you do not need the HTML docs.

Conclusion

You now have 7-Zip installed on Debian and can compress archives, extract common formats like ZIP and ISO, and encrypt sensitive data with AES-256. For RAR extraction on Debian 12, use the manual 7-Zip binary or our Debian unrar installation guide. For related file management tasks, explore our guide on enabling contrib and non-free repositories for additional software access.

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

  1. Thank you so much! I sware I feel like an idiot sometimes, but its through well documented pages like this that get me through. Im 47 now and been using linux of various flavors for a while, the thing is that I am just not so organized in my head. So i am grateful to you and i try to donate when i can, so I hope your feeling credited well for your service and likely I will be back and be able to help you also. God bless you (whichever one you know)!!

    1
    Reply

Leave a Comment