How to Install 7-Zip on Ubuntu, Debian, CentOS and Fedora
Install 7-Zip on Linux with one command per distribution, then create, extract, list and password-protect archives from the terminal.
2 min readBy Smita
Reviewed by the AmazingRDP technical team

Moving big archives between servers? A Linux VPS gives you root access and a fast connection. See Linux VPS from $6.99
7-Zip packs files into small archives and can lock them with strong encryption. On Linux it is a command-line tool called 7z. It opens its own 7z format and also ZIP, TAR, GZIP and many others. Installing it takes one command.
Install 7-Zip
Ubuntu and Debian:
sudo apt update
sudo apt install p7zip-full
On current releases this installs the newer 7zip package under the old name; the command is 7z either way.
Fedora:
sudo dnf install p7zip p7zip-plugins
CentOS Stream, RHEL, AlmaLinux, Rocky Linux: the packages are in the EPEL repository, so add that first.
sudo dnf install epel-release
sudo dnf install p7zip p7zip-plugins
Check that it works:
7z
It prints its version and a list of commands. If the shell answers "command not found", try 7zz or 7za: some packages use those names.
The commands you need
| Task | Command |
|---|---|
| Pack a folder | 7z a backup.7z myfolder/ |
| Unpack, keeping folders | 7z x backup.7z |
| Unpack into another folder | 7z x backup.7z -o/tmp/restore |
| List the contents | 7z l backup.7z |
| Test an archive | 7z t backup.7z |
| Make a ZIP file | 7z a -tzip files.zip myfolder/ |
| Strongest compression | 7z a -mx=9 backup.7z myfolder/ |
There is no space between -o and the folder name. Use x, not e, to unpack: e puts every file into one folder and loses the structure.
Protect an archive with a password
7z a -p -mhe=on secret.7z myfolder/
-p asks for the password without showing it. -mhe=on also hides the file names, so nobody can even list the contents without the password. The encryption is AES-256; there is no way back if you forget the password.
Split a large archive
7z a -v1g backup.7z bigfolder/
This writes parts of 1 GB each (backup.7z.001, .002 and so on). To unpack, keep all parts in one folder and open the first.
Two things to know on Linux
- Owners and permissions are not stored. The 7z format does not keep the Linux owner and group of files. For a backup of a system folder, pack it with
tarfirst and compress that file:tar cf - myfolder | 7z a -si backup.tar.7z. - RAR files. Unpacking RAR archives needs an extra package on some systems (
p7zip-raron Debian and Ubuntu).
On a desktop, the file manager uses 7-Zip by itself once the package is installed: right-click a file and choose to compress or extract. Related guides: fix "sudo: command not found" in Linux, upgrade pip on Ubuntu and, for a server of your own, Linux VPS plans.
Questions
What is the command to install 7-Zip on Ubuntu?
sudo apt install p7zip-full. The command to use it is 7z.
How do I extract a .7z file in Linux?
Run 7z x file.7z. Add -o/path to unpack somewhere else.
Why is p7zip not found on CentOS or RHEL?
The package is in the EPEL repository. Run sudo dnf install epel-release first.
Is 7-Zip free?
Yes. It is free, open-source software.