+4 votes
328 views
How to install and use 7z 7zip command to compress on Linux

in Linux / Unix by (552k points)
reopened | 328 views

1 Answer

+5 votes
Best answer

1. Install 7 Zip to compress on Linux
2. Create a compressed file with 7 Zip in Linux
3. Extract a compressed file with 7 Zip on Linux
4. Select the file format with 7 Zip in Linux
5. View files compressed with 7 Zip on Linux
6. Verify the integrity of a file with 7 Zip on Linux

Compression tools will always be one of the practical alternatives when it comes to managing our disk space or sending large files in a much smaller weight scheme. One of the most used compression utilities for its benefits is 7 Zip which is a free, open source tool and its code is under the GNU LGPL license..

Compatibility
It can be used in multiple operating systems without any problem using its options which are:
  • 7-Zip for Windows 10/8/7 / Vista / XP / 2016/2012/2008/2003/2000 / NT systems.
  • p7zip Which is the command line version of 7-Zip for Linux / Posix systems.
features
Some of the features when using 7 Zip are:
  • Compatible with formats such as AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z.
  • It has a command line utility for compression and decompression tasks.
  • It has a file manager for the storage of the elements to be managed within the utility.
  • Compatible with 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM extensions.
  • It can be integrated into Windows PowerShell.
  • Available in more than 80 languages.
  • It offers a compression ratio that is 2-10% for ZIP and GZIP formats.
  • It has self-extraction for the 7z format.
  • It has a plugin for FAR Manager.
  • It is possible to apply AES-256 encryption for 7z and ZIP formats

Now we will see how to install 7 Zip on Linux and take full advantage of its features.


1. Install 7 Zip to compress on Linux


The 7zip port for Linux systems is called p7zip, and this package is preinstalled in some Linux distributions, it will be necessary to install the p7zip-full package to obtain all CLI 7z, 7za and 7zr utilities in the system, to achieve this we will execute the following command according to the distribution to use:
Debian, Linux Mint or Ubuntu
In the case of Debian-based Linux distributions, there are three 7zip-related software packages which are p7zip, p7zip-full and p7zip-rar. It is recommended to install the p7zip-full package, which supports many file formats. To do this we execute the following:
 sudo apt-get install p7zip-full 
Fedora, CentOS and RedHat
In the case of RedHat-based Linux distributions, these have two 7zip-related packages and are p7zip and p7zip-plugins. It is advisable to install both packages. To install these two packages, the EPEL repository must be enabled on CentOS / RHEL distributions. In Fedora, it will not be necessary to configure an additional repository.

We execute the following once the EPEL repository is enabled. There we enter the letter S to confirm the download and installation..

 sudo yum install p7zip p7zip-plugins 
image

Now we will see some practical uses of 7 Zip in Ubuntu to make the most of its functionalities.


2. Create a compressed file with 7 Zip in Linux


To create a compressed storage file with the extension .7z, we can use the "a" parameter. The supported file formats for creating files are 7z, XZ, GZIP, TAR, ZIP and BZIP2, we execute the following syntax:
 7z to name. 7z "File to compress" 
image

3. Extract a compressed file with 7 Zip on Linux

Step 1

To extract a compressed .7z file, we will use the "e" option, which will extract the file in the current working directory:
 7z and name.7z 
image
Step 2

If the file already exists, as we see, it will be asked if we want to overwrite it, the final result will be the following: image

4. Select the file format with 7 Zip in Linux


To select a specific file format, we can use the -t (format name) option, which gives us the option to select some file format such as zip, gzip, bzip2 or tar (the default is 7z), we will use the following syntax:
 7z to -t ”format name” nomnbre.zip “file to compress” 
image

5. View files compressed with 7 Zip on Linux


To see a list of the files hosted in a compressed file, the "l" (list) parameter will be useful, which will show the type of file format, the method used, the files in the file, and much more:
 7z l name.7z 
image

6. Verify the integrity of a file with 7 Zip on Linux

Step 1

To test the integrity of a compressed storage file, we can use the "t" (test-test) option like this:
 7z t name.7z 
image
Step 2

Some additional options for use with 7 Zip are:
Create backup copies
To create a backup copy of a directory, it will be necessary to use the 7za utility which preserves the owner and / or group of a file, unlike 7z, the option - if you enable reading of stdin files, the syntax to use It will be as follows:
 tar -cf - "files" | 7th to -if “Files” .tar.7z 
Restore a backup
To restore a backup, we can use the -so option, which will send the output to stdout, we will use the following syntax:
 7za x -so “file” .tar.7z | tar xf - 
Define a compression level
To set a compression level, the -mx option will be useful like this:
 tar -cf - "files" | 7za to -si -mx = 8 name.tar.7z 
Update Files
To update an existing file or delete files from a tablet, we will use the "u" and "d" options, respectively as follows:
 7z or <file> <list of files to update> 7z d <file> <list of files to delete> 
Set password
To set a password for a 7 Zip storage file, we use the -p {password} flag:
 7za to -p {password} name.tar.7z 

In this way, 7 Zip is a viable and practical utility for all file compression work in Ubuntu environments with the best security and reach features offered by that utility..


by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Apr 30, 2020 in Linux / Unix by backtothefuture (552k points) | 308 views
+3 votes
1 answer
asked Oct 5, 2019 in Linux / Unix by backtothefuture (552k points) | 823 views
+3 votes
1 answer
+5 votes
1 answer
+5 votes
1 answer
asked Feb 22, 2020 in Linux / Unix by backtothefuture (552k points) | 348 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users