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 user
- Install the p7zip-full package on Ubuntu or Debian using apt.
$ sudo apt update && sudo apt install --assume-yes p7zip-full [sudo] password for user Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 p7zip-full amd64 16.02+dfsg-8build1 ##### snipped #####
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 ~/archives/extracted-archive
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 ~/archives/extracted-archive
- Run the 7z extraction command on the target archive.
$ 7z x ~/Downloads/archive.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (906ED),ASM,AES-NI) Scanning the drive for archives: 1 file, 189 bytes (1 KiB) Extracting archive: /home/user/Downloads/archive.7z -- Path = /home/user/Downloads/archive.7z Type = 7z Physical Size = 189 Headers Size = 189 Solid = - Blocks = 0 Everything is Ok Folders: 3 Files: 4 Size: 0 Compressed: 189
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 [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (906ED),ASM,AES-NI) Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [<@listfiles...>] <Commands> a : Add files to archive e : Extract files from archive (without using directory names) l : List contents of archive t : Test integrity of archive x : eXtract files with full paths <Switches> -ao{a|s|t|u} : set Overwrite mode -o{Directory} : set Output directory -p{Password} : set Password -r[-|0] : Recurse subdirectories -y : assume Yes on all queries ##### snipped ##### - Verify that the expected directories and files have been created in the extraction target.
$ ls -R ./ archive ./archive: subfolder-00 subfolder-01 ./archive/subfolder-00: filename-01 filename-02 ./archive/subfolder-01: filename-01 filename-02
- 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.
Comment anonymously. Login not required.
