- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Install and use 7zip on Linux
Linux is a popular open-source operating system that offers many advantages, such as being free, customizable, and secure. One of the challenges that Linux users face is finding the right tools for certain tasks, such as compressing and decompressing files. Fortunately, 7zip is a powerful and versatile compression tool that can help us with this task.
In this tutorial, we will walk through the process of installing and using 7zip in Linux. We will cover different ways to install 7zip, including via the command line and package manager, and provide step-by-step instructions with screenshots. We will also explain the basic usage of 7zip, such as how to compress and extract files and explore some of the advanced features and options available. By the end of this article, you will have a better understanding of how to install and use 7zip on Linux and be able to take advantage of its powerful capabilities.
Install and Use 7zip on Linux
7zip is a program that lets you compress and decompress files with ease. It supports a plethora of file formats like 7z, ZIP, RAR, and more. Some of the unique features of 7zip include −
Making files smaller so they take up less space on your computer
Splitting up large files into smaller ones
Adding a password to protect your files
Making self-extracting archives that can be opened without any special software
Let’s see how we can install this on our Linux system.
There are different ways to install 7zip on Linux, and in this article, we will show you two methods: using the command line and using the package manager.
Using Command Line
To install 7zip using the command line, we will need to use the terminal. If you are using a Debian-based Linux distribution, such as Ubuntu or Debian, you can install 7zip using the apt-get package manager. We simply need to open up a terminal window and enter the following command:
sudo apt-get install p7zip-full
For Fedora, CentOS, and other RPM-based distributions, use the following command:
sudo dnf install p7zip
For Arch Linux and other Arch-based distributions, use the following command:
sudo apt-get install p7zip
The above commands will download and install the 7zip package on our system.
Using Package Manager
If you prefer to use the package manager, you can open it from the applications menu. Look for the software center or package manager and search for "7zip". Then, click on the install button to begin the installation process.
Now that we’ve installed 7zip on your Linux system, let’s move to the next section of the article to understand how to use 7zip to compress and extract files.
To compress a file or a directory using 7zip, we use the ‘a’ option with the 7zip command followed by the name of the compressed file and the file to be compressed.
Consider the below command to compress a file using 7zip −
7z a compressed_file.7z file_to_compress
Replace "compressed_file.7z" with the name you want to give to the compressed file and "file_to_compress" with the name of the file or directory you want to compress.
For example, if we want to compress a directory named "Documents" into a file named "documents.7z", we can use the following command −
7z a documents.7z Documents/
When you execute the command shown above, a new file named "documents.7z" will be generated. This file will contain a compressed version of the "Documents" directory.
Compressing Mulitple Files or Directories
If you want to compress multiple files or directories with a single command, you can separate them with spaces −
7z a compressed_files.7z file1.txt file2.txt directory1/ directory2/
After executing the command as demonstrated above, a new file called "compressed_files.7z" will be created, which contains a compressed version of the files "file1.txt", "file2.txt", "directory1/" and "directory2/".
To extract a file or a directory using 7zip, we use the ‘x’ option with the 7zip command followed by the name of the file to be extracted.
Consider the below command to extract a file using 7zip −
7z x compressed_file.7z
Replace "compressed_file.7z" with the name of the compressed file you want to extract. For example, if we want to extract the "documents.7z" file we created earlier, we can use the following command −
7z x documents.7z
When you run the command shown above, the contents of the "documents.7z" file in the current directory will be extracted.
Extracting Files to a Specific Directory
If you want to extract the contents of a compressed file to a specific directory, you can use the "-o" option followed by the path to the directory −
7z x compressed_file.7z -o /downloads/
Executing the command shown above will extract the contents of the "compressed_file.7z" file in the "Downloads" folder.
In addition to the basic features of compression and extraction, 7zip also offers some advanced options to enhance your experience and provide security. For example:
You can secure your compressed files by using encryption. This feature allows you to set a password to protect your files from unauthorized access.
To encrypt your files, use the -p option followed by a password when compressing your files. For example, to compress the "Documents" directory with a password of "mypassword", run the following command −
7z a -pmypassword Documents.7z Documents/
When you try to extract the encrypted zip file, 7zip will ask you for a password, and will open the file if the password is entered correctly.
2. Splitting Archives
Sometimes, you may need to split a large file into smaller parts for easier sharing or storage. With 7zip, you can split your archives into multiple parts based on the desired size.
To split your archives, use the -v option followed by the desired size in bytes. For example, to split the "Documents" directory into 10MB parts, run the following command −
7z a -v10m Documents.7z Documents/
To extract the split files, extract the first part of the archive as usual, and 7zip will automatically extract the rest of the parts.
3. Custom Compression Levels
7zip also offers various compression levels to choose from. Depending on your needs, you can choose the level of compression that suits you best. Higher compression levels will take longer to compress and decompress but will result in smaller file sizes.
To choose a custom compression level, use the -mx option followed by a number from 1 to 9. For example, to use the highest compression level, run the following command −
7z a -mx9 Documents.7z Documents/
Lower compression levels can be faster to compress and decompress, but will result in larger file sizes.
In this article, we have learned about 7zip, a powerful compression tool that can be installed and used on Linux. We have covered different ways to install 7zip, such as via the command line and package manager, and have provided step-by-step instructions. We have also explained the basic usage of 7zip, such as how to compress and extract files, and explored some of the advanced features and options available, such as encryption and creating self-extracting archives.
Kickstart Your Career
Get certified by completing the courseGet Started