How can I insert 7Zip in Ubuntu, Debian, Centos & Fedora

Published October 26, 2023

Linux users face file compression and sending challenges, but 7Zip can help. This free and open-source program works on multiple platforms, including Linux. We’ll cover how to insert 7Zip on Linux and its practical use in Ubuntu, Debian, CentOS, and Fedora.

7Zip

Explore More ; How to Reinstall Ubuntu Linux

What is 7Zip and How it Works?

7-Zip is a free and open-source application that compresses files into archives.

It was created by Igor Pavlov in 1999 and supports various formats, including its own 7z format.

7Z files are easy to upload and download due to their excellent compression ratio and encryption capabilities.

Additionally, 7Zip can extract files from a variety of formats, such as ZIP, RAR, and ISO. The archived files are saved with the 7Z file extension and use AES-256 encryption for added security. Using 7Z files can help free up space on your hard drive and make file sharing over the internet more efficient.

Reducing the size of files to save space on your computer, Creating smaller versions of massive files, Adding a password to your files to safeguard them, and Creating self-extracting archives that don’t require any specific software to open are the most brilliant features of the 7Zip tool.

Install 7Zip in Linux Ubuntu, Debian, CentOS and Fedora

Let’s go through this tutorial and review two ways to Install 7Zip in Linux. Using the methods, you can install and use the 7Zip program in Ubuntu, Debian, CentOS, and Fedora. Compress & Extract File in Linux is also possible using Linux commands. This guide teaches you how you can install and use the 7Zip compression tool to do this.

 

Using the Command line and Package manager methods, you can install 7Zip in Linux. If you prefer any of them, skip the other one to save your time.

Install 7Zip in Linux Using Command Line

First, let’s see how to install 7Zip in Linux using the command line. So, you need to open up a terminal window (Ctrl + T) and run the related command of your current distribution to download and install the 7zip package on your system.

 

Install 7Zip On Ubuntu and Debian:

 

Run the command below on your Debian-based Linux distribution to install 7Zip on it:

sudo apt updates

udo apt-get install p7zip-full

Install 7-Zip On CentOS and Fedora:

If you are using RPM-based distribution, type:

sudo dnf install p7zip

P7zip and p7zip-plugins, the dynamic duo of packages associated with 7zip, come bundled with Red Hat-based Linux distributions.

It is highly recommended to install both packages for optimal performance.

However, if you’re using CentOS/RHEL versions, there’s a small hoop to jump through. You’ll need to enable the EPEL repository before you can get your hands on these two packages. But fear not, for Fedora users, no additional repositories need to be set up. So, get ready to unleash the power of 7zip on your Linux system!

$ sudo yum install p7zip p7zip-plugins

When you are finished, you can use the following command to check whether the package is installed:

$ 7z

Install 7Zip Using Package Manager

To simplify the installation of 7Zip in Linux, use the package manager. Access the applications menu, search for “7zip” in the software center or package manager, and click the install button. This streamlines the process, allowing you to enjoy 7Zip on your Linux system effortlessly.

Examples to Use 7Zip in Ubuntu, Debian, CentOS & Fedora

Thus far, you have acquired the knowledge of installing the esteemed 7Zip software on your Linux system.

By implementing any of the aforementioned methods, you have successfully installed 7Zip on your system. Now, in this segment, you shall be enlightened on the art of utilizing 7Zip in Linux.

7Zip Syntax

7z <command> [<switch>…] <base_archive_name> [<arguments>…] [<@listfiles…>]

7Zip Commands

OPTION               USAGE

a.                         Add files to archive

b.                         Benchmark

d.                         Delete files from archive

e.                        Extract files from archive (without using directory names)

l.                        List contents of the archive

t.                       Test integrity of the archive

x.                      Extract files with full paths

U.                     Update files to archive

Compress Files Using 7Zip in Linux

When using the 7zip program to compress a file or directory, the ‘a‘ option is used together with the names of the compressed and uncompressed files.

 

Run the command below to compress a file using the 7zip tool:

7z a compressed_file.7z file_to_compress

Replace “file_to_compress” with the name of the file or directory you wish to compress, and “compressed_file.7z” with the name you wish to give the compressed file.

 

Use the command below to compress a directory called “home” into a file named “home.7z”

7z a home.7z home/

In this way, the new file named ”home.7z” will be created which contains a compressed version of the ”home” directory.

Extract Files Using 7Zip in Linux

Using the 7zip program, you can extract files or directories by using the ‘x‘ option with the 7zip command and the file’s name. To do this, run the following command and extract your considered file:

7z x compressed_file.7z

The name of the compressed file you want to extract should be substituted for “compressed_file.7z“. For instance, we can use the command below to extract the “home.7z” file we previously prepared.

7z x home.7z

The ”home.7z” file must be extracted in the current directory.

Compress Multiple Files/Directories

To compress multiple files or directories, separate them with spaces:

7z a compressed_files.7z file1.txt file2.txt directory1

A new file called “compressed_files.7z,” which contains a compressed version of the files “file1.txt,” “file2.txt,” “directory1/,” and “directory2/,” will be produced after the command has been run.

Extract Files to a Specific Directory

To extract the content of a compressed file to a specific directory, run the command as shown below:

7z x compressed_file.7z -o /media/

In this way, the “compressed_file.7z” file in the “media” folder will be extracted.

Extract Archive in the Currently Active Working Directory

To extract an .7z archive file, use “e” option like the below example:

$ 7z e example.7z

Select an Archive Format

Use the -t (format name) option to choose an archive format, from which you can choose zip, gzip, bzip2, or tar (the default is 7z):

$ 7z a -tzip example.zip example_deb

Print an Archive Files

Use the “l” (list) function to view a list of the files in an archive. This function displays the type of archive format, method, items in the archive, and other information.

$ 7z l example.7z

Check the Integrity of an Archive File

Use the “t” (test) function as demonstrated to check the integrity of an archive file.

$ 7z t example.7z

Backup a Directory with 7Z in Linux

You can use the 7za program to back up directories since it keeps track of a file’s owner and group. Unlike 7z, the -si option allows reading from stdin.

$ tar -cf – example_files | 7za a -si example_files.tar.7z

Restore a Backup

Using -so option enables you to restore a backup by sending output to stdout.

$ 7za x -so example_files.tar.7z | tar xf –

Adjust Compression Level

To set a compression level, you can use the -mx option:

$ tar -cf – example_files | 7za a -si -mx=9 example_files.tar.7z

Update & Remove Files

Use the “u” and “d” options, respectively, to add new files to an archive file or remove existing files from an archive file.

$ 7z u <archive-filename> <list-of-files-to-update>

$ 7z d <archive-filename> <list-of-files-to-delete>

Set a Password to Files

Use the -p option to set a password for an archive file:

$ 7za a -p{password_here} example_secrets.tar.7z

Create Archive File [GUI method]

To effortlessly create an archive file and folders without complicated commands or Terminal wizardry, follow these simple steps:

 

1. Navigate to the location of the file you want to archive.

2. Right-click on the file to reveal a magical pop-up menu.

3. Select the compress option from the menu.

4. Watch as technology works its magic, generating an archive file that includes your chosen file and accompanying folders.

 

No need for complex commands or intimidating Terminal windows. This user-friendly method allows even the least tech-savvy individuals to create an archive file with elegance.

Embrace the simplicity and let your files find solace within the cozy confines of an archive.

The dialog box offers you three fantastic archive options: .zip, .tar.xz, and .7z. In this particular scenario, we’ll go with .zip to create a compressed file named myfile.zip.

Explore More ; Debian vs Ubuntu | Which is the Best Linux Distro?

GET CONNECTED WITH US ON ,
Facebook,TwitterInstagram.