7-Zip is a free open source, cross-platform, powerful, and fully-featured file archiver with a high compression ratio, for Windows. It has a powerful command line version that has been ported to Linux/POSIX systems.

 

It has a high compression ratio in 7z format with LZMA and LZMA2 compression, supports many other archive formats such as XZ, BZIP2, GZIP, TAR, ZIP and WIM for both packing and unpacking; AR, RAR, MBR, EXT, NTFS, FAT, GPT, HFS, ISO, RPM, LZMA, UEFI, Z, and many others for extracting only.

 

It provides strong AES-256 encryption in 7z and ZIP formats, offers a compression ratio that of 2-10 % for ZIP and GZIP formats (much better than those offered by PKZip and WinZip). It also comes with self-extracting capability for 7z format and it’s localized in up-to 87 languages.

 

How to Install 7zip in Linux

 

The port of 7zip on Linux systems is called p7zip, this package comes pre-installed on many mainstream Linux distributions. You need to install the p7zip-full package to get the 7z, 7za, and 7zr CLI utilities on your system, as follows.

 

Install 7zip on Debian, Ubuntu or Linux Mint

 

Debian-based Linux distributions comes with three software packages related to 7zip and they are p7zip, p7zip-full and p7zip-rar. It is suggested to install p7zip-full package, which supports many archive formats.

$ sudo apt-get install p7zip-full

 

Install 7zip on Fedora or CentOS/RHEL

 

Red Hat-based Linux distributions comes with two packages related to 7zip and they are p7zip and p7zip-plugins. It is suggested to install both packages.

 

To install these two packages, you need to enable EPEL repository on CentOS/RHEL distributions. On Fedora, no need to setup additional repository.

$ sudo yum install p7zip p7zip-plugins

 

Once the 7zip package installed, you can move further to learn some useful 7zip command examples to pack or unpack various types of archives in the following section.

 

Learn 7zip Command Examples in Linux

 

1. To create an .7z archive file, use "a" option. The supported archive formats for creation are 7z, XZ, GZIP, TAR, ZIP and BZIP2. If the given archive file exists already, it will “add” the files to an existing archive, instead of overwriting it.

$ 7z a hyper.7z hyper_1.4.2_i386.deb

 

2. To extract an .7z archive file, use "e" option, which will extract the archive in the present working directory.

$ 7z e hyper.7z

 

3. To select an archive format, use -t (format name) option, which will allows you to select the archive format such as zip, gzip, bzip2 or tar (the default is 7z):

$ 7z a -tzip hyper.zip hyper_1.4.2_i386.deb

 

4. To see a list of files in an archive, use "l" (list) function, which will displays the type of archive format, method used, files in the archive among other information as shown.

$ 7z l hyper.7z

 

5. To test the integrity of an archive file, use "t" (test) function as shown.

$ 7z t hyper.7z

 

6. To backup a directory, you should use the 7za utility which preserves owner/group of a file, unlike 7z, the -si option enables reading of files from stdin.

$ tar -cf - rootadminz_files | 7za a -si rootadminz_files.tar.7z

 

7. To restore a backup, use -so option, which will sends output to stdout.

$ 7za x -so rootadminz_files.tar.7z | tar xf -

 

8. To set a compression level, use the -mx option as shown.

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

 

9. To update an existing archive file or remove file(s) from an archive file, use "u" and "d" options, respectively.

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

 

10. To set a password to an archive file, use -p {password_here} flag as shown.

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

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)