7-Zip is a file archiver with a high compression ratio. It is free software with open source.
You can use 7-Zip on any computer, including a computer in a commercial organization. You don’t need to register or pay for 7-Zip.
7-zip support multiple formats including:
Packing and Unpacking for 7z, XZ, BZIP2, GZIP, TAR, ZIP and WIM formats.
Only Unpacking for 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.
7-zip does not come with Linux by default you need to install it. If you are using Ubuntu you can simply run and it will install the required binaries.
$ sudo apt-get install p7zip-full
If you want to work with the rar files then you need to install the 7zip with rar as follows:
$ sudo apt-get install p7zip-rar
Basic Syntax of 7-zip
7z [abdeltux] [switches…] [archive_name] [file_names…]
Creating an Archive with 7zip
Option ‘a’ is to create archives. Following is an example of how you can create an archive from multiple files.
$ 7z a files1and2 file1 file2
Lets say you have multiple files in a directory and you want to create an archive including all of them. You can do that as follows.
$ 7z a files *
output will be: files.7z
Listing the Archived Files with 7zip
if you have downloaded a file with 7z extension or you in past created a 7zip archive and you want to see the files inside the archive then you can use the ‘l’ option.
$ 7z l archived_file.7z
Updating the 7zip Archive
You can add more files to an already created archive using ‘u’ option.
$ 7z archived_file.7z new_file new_file
Deleting Files from 7zip Archive
If you need to remove the file from the archive you can do that with ‘d’ option.
$ 7z d archived_file.7z file_to_be_deleted
Extracting Files from 7zip Archive
Option ‘x’ is used to extract the files from the archive.
$ 7z x archived_file.7z
That’s it, you can use 7zip to manage file compression and decompression on the Linux system. You can also make use of (man 7z) Linux manual pages to find out more information on 7zip.