P7Zip is required to extract certain archive files, especially the .7z kind. It isn’t available in the RHEL 8 repositories, so you’re going to need to get it elsewhere. For that, there are two options, the EPEL
and building it from source. Both work well.
In this tutorial you will learn:
- How to Install P7Zip From the EPEL
- How to Download the P7Zip Source
- How to Install the Build Tools
- How to Build and Install P7Zip
- Basic examples on how to extract and compress 7z files
Software Requirements and Conventions Used
|Category||Requirements, Conventions or Software Version Used|
|System||RHEL 8 / CentOS 8|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to Install P7Zip From the EPEL
- P7Zip is packaged and ready to use in the EPEL. If you don’t already have it, enable the EPEL on your system.
Now, install package P7Zip normally with DNF.
# dnf install p7zip p7zip-plugins
How to Download, Install and Complie the P7Zip from Source
If, the EPEL isn’t available for some reason, or the package becomes outdated, you can always build P7Zip from its source. It’s not an overly large application, so it doesn’t take long.
- Begin by downloading the P7Zip source tarball from SourceForge. Locate and download the latest tarball from the P7Zip repository.
- Unpack the tarball where you would like to build.
$ tar xjpf p7zip_16.02_src_all.tar.bz2
- Install the Build ToolsYou’ll need the build tools in order to compile P7Zip. If you haven’t already installed them, do a group install with DNF to get everything that you’ll need.
# dnf groupinstall 'Development Tools'
- Build and Install P7ZipNow,
cdinto the source directory that you unpacked.
$ cd p8zip_16.02
There are a few different ways that you can build P7Zip that contain different sets of utilities and plugins. To get everything, use the
-j4flag here tells make to use 4 CPU cores.
$ make -j4 all3
P7Zip provided an install script to put everything that you just built in the correct place. Run it with root privileges to install P7Zip and all the associated plugins that you just built.
After it finishes, it’ll tell you everything that it installed and where it put everything.
How to extract and compress files with P7Zip examples
To create a compressed archive named
archive.7z of a
Archvie directory execute:
$ 7za a archive.7z Archive
To extract files from the 7z compressed file use the
$ 7za e archive.7z
Whichever way you chose to install P7Zip, you’ll have full access to it and its plugins now. If you opted for the source install, you’re going to need to check regularly for updates. You can always uninstall the source build when an acceptable version becomes available in the EPEL.