7z archives are common for backups, software bundles, and large transfers because they compress aggressively while keeping whole directory trees in one file. Extracting a .7z archive on Linux restores the original files so they can be reviewed, edited, or deployed normally.
On Linux, extraction is handled by the 7z command. The l command lists what is stored inside an archive, while x recreates the archived directory structure and writes the files into the chosen destination. Current Debian and Ubuntu releases package this tool as 7zip, while other distributions may ship the same 7z command through different package names.
Before extracting, confirm that the target location has enough free space and that the archive came from a trusted source. If files with the same names already exist, 7z can prompt before overwriting them, and encrypted archives prompt for a password during extraction unless one is supplied explicitly.
Related: Extract ZIP files, Extract RAR files, Extract XZ files.
Steps to extract 7z files in Linux:
- Open a terminal on the Linux system.
- Change to the directory that contains the .7z archive.
$ cd /tmp/restore-demo $ ls project-backup.7z
Replace /tmp/restore-demo with the directory that contains the archive on the local system.
- Install the package that provides the 7z command if it is not already available.
$ command -v 7z || echo "7z not found" /usr/bin/7z
Examples: on current Debian or Ubuntu releases, install 7zip with
$ sudo apt update && sudo apt install --assume-yes 7zip
Older guides may still refer to p7zip-full, but current 7zip packages provide the same 7z command. On Fedora, install p7zip and p7zip-plugins with
$ sudo dnf install --assumeyes p7zip p7zip-plugins
On other distributions, install the package that provides the 7z command.
- List the archive contents before extraction.
$ 7z l project-backup.7z 7-Zip 23.01 (arm64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20 64-bit arm_v:8 locale=C.UTF-8 Threads:8 OPEN_MAX:1048576 Scanning the drive for archives: 1 file, 252 bytes (1 KiB) Listing archive: project-backup.7z -- Path = project-backup.7z Type = 7z Physical Size = 252 Headers Size = 230 Method = LZMA2:12 Solid = + Blocks = 1 Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2026-04-14 00:50:58 D.... 0 0 project-backup 2026-04-14 00:50:58 D.... 0 0 project-backup/reports 2026-04-14 00:50:58 ....A 6 22 project-backup/alpha.txt 2026-04-14 00:50:58 ....A 5 project-backup/beta.log 2026-04-14 00:50:58 ....A 7 project-backup/reports/report.txt
The l command shows the stored paths without writing any files, which helps confirm whether the archive already contains a top-level directory.
- Create a target directory for the restored files.
$ mkdir -p restore
Extracting into an empty directory keeps the restored content separate from existing files and makes cleanup easier.
- Extract the archive with full paths into that directory.
$ 7z x project-backup.7z -o./restore 7-Zip 23.01 (arm64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20 64-bit arm_v:8 locale=C.UTF-8 Threads:8 OPEN_MAX:1048576 Scanning the drive for archives: 1 file, 252 bytes (1 KiB) Extracting archive: project-backup.7z -- Path = project-backup.7z Type = 7z Physical Size = 252 Headers Size = 230 Method = LZMA2:12 Solid = + Blocks = 1 Everything is Ok Folders: 2 Files: 3 Size: 18 Compressed: 252
Switch -o sets the output directory with no space before the path. The x command preserves the archived directory structure. Use e instead only when all files should be extracted into one flat directory.
- Control overwrite behavior when extracting into a directory that already contains files.
$ 7z x project-backup.7z -o./restore -aos
Use -aos to skip existing files or -aoa to overwrite them automatically. Without an overwrite switch, 7z can prompt when names collide.
- Verify that the expected files and directories were restored.
$ find restore -maxdepth 3 -print | sort restore restore/project-backup restore/project-backup/alpha.txt restore/project-backup/beta.log restore/project-backup/reports restore/project-backup/reports/report.txt
If the archive is encrypted, 7z prompts for the password during extraction. Avoid passing passwords inline with -p unless a non-interactive workflow explicitly requires it.
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.
