How to Install 7-Zip on Raspberry Pi Linux

This guide provides a straightforward walkthrough for installing and using 7-Zip on Raspberry Pi single-board computers running Linux. You will learn how to update your package repositories, install the appropriate 7-Zip package using the APT package manager, verify the installation, and execute essential commands for compressing and extracting archives directly from the command line.

Step 1: Update Your System

Before installing any new software, ensure your package lists and installed software are up to date. Open your terminal and run:

sudo apt update && sudo apt upgrade -y

Step 2: Install 7-Zip via APT

Depending on the version of Raspberry Pi OS (or Debian-based distribution) you are running, 7-Zip is available either as the modern upstream port (7zip) or the legacy port (p7zip-full).

For Raspberry Pi OS Bookworm (and newer)

Modern releases include the official upstream 7-Zip package:

sudo apt install 7zip -y

For Raspberry Pi OS Bullseye (and older)

Older releases use the legacy POSIX port of 7-Zip:

sudo apt install p7zip-full p7zip-rar -y

Step 3: Verify the Installation

Confirm that the software was installed correctly by checking the installed version.

If you installed the modern 7zip package, use:

7zz

If you installed p7zip-full, use:

7z

The output will display the version number, copyright information, and a list of supported commands and switches.

Step 4: Common Usage Commands

Replace 7z with 7zz in the following commands if you are using the modern 7zip package.

Extract an Archive

To extract files while preserving the original folder structure, use the x command:

7z x archive.7z

To extract files to a specific directory:

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

Create a New Archive

To compress files or directories into a .7z archive, use the a (add) command:

7z a archive.7z file1.txt file2.txt /path/to/folder

To compress an archive with maximum compression:

7z a -mx=9 archive.7z /path/to/folder

List Archive Contents

To view the contents of an archive without extracting it:

7z l archive.7z

Test Archive Integrity

To verify that an archive is not corrupted:

7z t archive.7z