Compressed .7z archives reduce file size and group related files, making backups, transfers, and downloads on Linux efficient and tidy. Extracting these archives restores their contents to a regular directory for editing, packaging, or deployment. Reliable extraction avoids partially restored directory trees or corrupted files when working with shared projects and downloaded resources.
On Linux, .7z support is provided by the p7zip tools, which expose the 7-Zip engine through the 7z command-line utility. The extractor reads the archive, reconstructs the directory structure, and writes each file to the selected target directory while preserving metadata where possible. Many desktop environments integrate p7zip into file managers such as GNOME Files and KDE Dolphin so graphical extraction works alongside the terminal.
Some .7z archives are password protected or contain many gigabytes of data, so sufficient disk space and the correct passphrase are required before starting extraction. Extracting into a dedicated directory avoids mixing new files with existing ones and makes cleanup straightforward. When working on multi-user systems, placing extracted data inside a home directory rather than shared system paths reduces permission issues and accidental overwrites.
Steps to unzip 7z files in Linux:
- Open a terminal on the Linux system with a user account that can run sudo.
$ whoami root
- Install the p7zip-full package on Ubuntu or Debian using apt.
$ sudo apt update && sudo apt install --assume-yes p7zip-full
For CentOS and Red Hat Enterprise Linux, enable EPEL and install p7zip instead.
$ sudo yum install --assumeyes epel-release $ sudo yum install --assumeyes p7zip
- Create a dedicated directory to hold the extracted contents of the .7z archive (optional).
$ mkdir -p /root/sg-work/archives/target-7z
Keeping extraction in a separate folder avoids mixing new files with existing data.
- Change into the directory that should receive the extracted files (optional).
$ cd /root/sg-work/archives/target-7z
- Run the 7z extraction command on the target archive.
$ 7z x /root/sg-work/archives/source.7z 7-Zip 23.01 (arm64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20 64-bit arm_v:8 locale=en_US.UTF-8 Threads:2 OPEN_MAX:1024 Scanning the drive for archives: 1 file, 243 bytes (1 KiB) Extracting archive: /root/sg-work/archives/source.7z -- Path = /root/sg-work/archives/source.7z Type = 7z Physical Size = 243 Headers Size = 221 Method = LZMA2:12 Solid = + Blocks = 1 Everything is Ok Folders: 2 Files: 3 Size: 18 Compressed: 243
Encrypted archives prompt for a passphrase before extraction and fail with an error if the password is incorrect.
- Review common 7z options when additional control over extraction is required.
Common options for the 7z command:
$ 7z --help 7-Zip 23.01 (arm64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20 64-bit arm_v:8 locale=en_US.UTF-8 Threads:2 OPEN_MAX:1024 Usage: 7z <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 ##### snipped #####
- Verify that the expected directories and files have been created in the extraction target.
$ ls -R ./ source ./source: alpha.txt beta.log reports ./source/reports: report.txt
- Use the graphical file manager to extract a .7z archive from the context menu when a terminal is not required.
In GNOME Files and KDE Dolphin, right-click the archive, choose Extract Here or Extract to..., and select the destination directory.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
