How can I Install 7-Zip in Ubuntu, Debian, Centos & Fedora
As a Linux user, you might face issues in sending large files or compressing/decompressing them. While 7Zip is used from a Windows GUI, Linux users can also benefit from this cross-platform file archiver. 7Zip is a free and open-source compression program that is available on Linux with a powerful command line version. Installing 7Zip on Linux is possible through different methods, and this article will explain them all in detail. By utilizing practical examples, you will also acquire knowledge of the utilization of 7Zip in Ubuntu, Debian, CentOS, and Fedora.
Almost all operating systems can open ZIP files, but to work with 7Z files, users must install 7-Zip or another third-party program that supports them. It’s still a reliable compression format. After buying a Linux VPS, you will need to compress and extract files or folders to do your daily tasks. This guide shows you how to install and use 7Zip on Linux and take advantage of its capabilities.
What is 7-Zip and How Does It Work?
7-Zip is a software tool designed for compressing files into containers called “archives.” Developed by Igor Pavlov and first released in 1999, it is a free and open-source application. Although it primarily utilizes its own 7z archive format, 7-Zip is quite versatile and supports a broad range of file formats. Similar to ZIP and RAR, 7Z files are archives created with the 7-Zip software, renowned for their impressive compression ratio and robust encryption capabilities.
7-Zip can handle a variety of archive formats for both compression and extraction, including XZ, BZIP2, GZIP, TAR, ZIP, and WIM. For extraction only, it supports formats such as AR, RAR, MBR, EXT, NTFS, FAT, GPT, HFS, ISO, RPM, LZMA, UEFI, Z, and many others. Archives created with 7-Zip are typically saved with a .7z extension. Compared to other formats like ZIP, TAR.GZ, RAR, and ISO, 7Z files provide better compression ratios and AES-256 encryption. This efficiency helps to conserve disk space and facilitates easier file transfers over the internet.
Key features of 7-Zip include:
- Reducing file sizes to free up disk space.
- Creating more compact versions of large files.
- Adding passwords to secure your files.
- Generating self-extracting archives that do not require additional software to open.
Stay tuned to learn how to install 7-Zip on Linux in the rest of this tutorial.
Two Methods to Install 7-Zip on Linux (Ubuntu, Debian, CentOS, and Fedora)
This guide outlines two methods for installing 7-Zip on Linux distributions, including Ubuntu, Debian, CentOS, and Fedora. You can choose between using the command line or the package manager to install and use the 7-Zip compression tool.
Installing 7-Zip via Command Line
To install 7-Zip using the command line, follow the steps below based on your Linux distribution.
On Ubuntu and Debian:
Open a terminal window (Ctrl + T).
Run the following commands:
sudo apt update
sudo apt-get install p7zip-full
On CentOS and Fedora:
Open a terminal window.
For RPM-based distributions, use:
sudo dnf install p7zip
Note: For CentOS/RHEL, you need to enable the EPEL repository to install p7zip and p7zip-plugins:
sudo yum install p7zip p7zip-plugins
Verify the installation by running:
7z
Installing 7-Zip Using the Package Manager
If you prefer using the package manager, follow these steps:
Open your applications menu and find the software center or package manager.
Search for “7zip.”
Click the install button to start the installation process.
Practical Examples of Using 7-Zip on Linux
Once 7-Zip is installed, you can use it to compress and extract files.
The general syntax for 7-Zip commands is:
7z
[…] […] [<@listfiles…>]
7-Zip Commands
Here are some essential 7-Zip commands and their usage:
Option Usage
a Add files to an archive
b Benchmark
d Delete files from an archive
e Extract files from an archive (without directory names)
l List contents of the archive
t Test integrity of the archive
x Extract files with full paths
U Update files in the archive
Compress Files Using 7-Zip in Linux
To compress a file or directory using 7-Zip, use the a option along with the names of the compressed and uncompressed files.
Compress a file:
7z a compressed_file.7z file_to_compress
Replace file_to_compress with the file or directory you want to compress and compressed_file.7z with the desired name for the compressed file.
Compress a directory:
7z a home.7z home/
This command creates a file named home.7z that contains a compressed version of the home directory.
Extract Files Using 7-Zip in Linux
To extract files or directories, use the x option with the 7-Zip command.
Extract files:
7z x compressed_file.7z
Replace compressed_file.7z with the name of the file you wish to extract.
Example extraction:
7z x home.7z
This command extracts the home.7z file into 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/ directory2/
This command creates compressed_files.7z, containing a compressed version of the specified files and directories.
Extract Files to a Specific Directory
To extract files to a specific directory, use the -o option:
7z x compressed_file.7z -o /media/
This extracts the contents of compressed_file.7z to the /media/ directory.
Extract Archive in the Currently Active Working Directory
To extract an archive file using the e option:
7z e example.7z
Select an Archive Format
To specify an archive format, use the -t option:
7z a -tzip example.zip example_deb
This command creates a ZIP archive instead of the default 7z format.
Print Archive Files
To list the files in an archive, use the l (list) function:
7z l example.7z
This displays the contents and details of example.7z.
Check the Integrity of an Archive File
To test the integrity of an archive file:
7z t example.7z
Backup a Directory with 7-Zip in Linux
To back up a directory, using 7za (a variant of 7-Zip):
tar -cf – example_files | 7za a -si example_files.tar.7z
Restore a Backup
To restore a backup from a 7-Zip archive:
7za x -so example_files.tar.7z | tar xf –
Adjust Compression LevelTo set a compression level, use the -mx option:
tar -cf – example_files | 7za a -si -mx=9 example_files.tar.7z
Update & Remove Files
7z u Remove files from an archive:
7z d Set a Password for Files
To set a password for an archive file:
7za a -p{password_here} example_secrets.tar.7z
Create Archive File [GUI Method]
To create an archive file using a GUI:
Navigate to the file location.
Right-click the file.
Select the “Compress” option from the context menu to generate an archive file.
Feel free to use these commands and options to effectively manage your files and archives with 7-Zip on Linux.
Creating an Archive File Without Using Commands or Terminal
To create an archive file using a graphical interface rather than commands or the terminal:
Open the File Location: Navigate to the folder where the file or folder you want to compress is located.
Select the File/Folder: Highlight the file or folder you wish to compress.
Right-Click: Right-click on the selected file or folder to open the context menu.
Choose Compression Option: From the menu, select the “Compress” or “Create Archive” option.
Select Archive Format: A dialog box will appear, allowing you to choose from different archive formats. For this example, select .zip.
Name the Archive: Enter the desired name for your compressed file (e.g., myfile.zip).
Create the Archive: Click on the “Create” or “OK” button to generate the compressed file.
Conclusion
In this guide, you learned how to install and use 7-Zip on Linux distributions such as Ubuntu, Debian, CentOS, and Fedora. You explored various commands and methods for compressing and extracting files using 7-Zip. The 7-Zip archiver is a powerful tool for efficiently managing your files and folders, making data transfer easier.
If you followed the steps outlined and encountered any issues, don’t hesitate to reach out for support. Our technical team is here to help resolve any problems you might face.