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
Install P7Zip on RHEL 8
Install P7Zip on RHEL 8

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System RHEL 8 / CentOS 8
Software P7Zip
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ - requires given linux commands to be executed as a regular non-privileged user

How to Install P7Zip From the EPEL

  1. P7Zip is packaged and ready to use in the EPEL. If you don't already have it, enable the EPEL on your system.
  2. Now, install package P7Zip normally with DNF.

    SUBSCRIBE TO NEWSLETTER
    Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


    # 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.

  1. Begin by downloading the P7Zip source tarball from SourceForge. Locate and download the latest tarball from the P7Zip repository.
  2. Unpack the tarball where you would like to build.

    $ tar xjpf p7zip_16.02_src_all.tar.bz2
  3. Install the Build Tools

    You'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'
  4. Build and Install P7Zip Now, cd into the source directory that you unpacked.
    $ cd p8zip_16.02
    Build P7Zip on RHEL 8
    Build P7Zip on RHEL 8.

    There are a few different ways that you can build P7Zip that contain different sets of utilities and plugins. To get everything, use the all3 option with make. The -j4 flag here tells make to use 4 CPU cores.

    $ make -j4 all3
    P7Zip Installed on RHEL 8
    P7Zip Installed on RHEL 8.


    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.

    # ./install.sh
  5. 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 e switch:
    $ 7za e archive.7z
    
    Extract and Compress 7z files example on RHEL 8 Linux
    Extract and Compress 7z files example on RHEL 8 Linux

    Conclusion

    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.

ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.