Start compressing your file by installing 7-Zip on Ubuntu 22.04 LTS Jammy JellyFish using the command terminal or GUI interface.
7-Zip is a popular free and open-source ZIP program that allows you to create and unzip archive files, also the RAR format is supported. It helps us to compress files and documents as well as unpack compressed folders. 7-Zip supports 7z, ZIP, RAR, GZIP, BZIP2, TAR, CAB, ISO, ARJ, LZH, CHM, Z, CPIO, RPM, DEB, and NSIS formats. However, it achieves the highest compression rate with the in-house 7z format. With the 7z format, you can even create self-extracting archives. In addition to the graphical interface, 7-Zip has a powerful command-line version.
Steps to install 7-Zip on Ubuntu 22.04 LTS Linux
The steps are given here can be used for other Ubuntu versions such as 20.04/18.04 including Debian, Linux Mint, POP_OS, Elementary OS, and other similar Linux.
1. Perform a System update
In this tutorial we will use the APT package manager and system default source repository, hence first, run the system update command to refresh and rebuild its cache.
sudo apt update
2. Install 7-zip on Ubuntu 22.04 LTS
The installation of 7-zip doesn’t require any third-party repository; we can install it using Ubuntu’s standard one. Hence, just run the given command that uses the APT package manager to install the 7-zip complete package.
sudo apt install p7zip-full
To check its version and options to use, we can use:
7z -h
3. 7Zip Command line to compress files
7-zip offers a quick command-line method to create archive files in the terminal using 7Zip will be:
7z a folder-name.7z folder-name
Therefore, for example, if we say the folder name that we want to compress is “pics” then the command will be like this
7z a pics.7z pics
To use any other archive format use that extension, for example, to get the archive in zipped format, the command will be like this way:
7z a pics.zip pics
Here is the output:
4. To List the content of the file
If you want to see what is inside some archive but without extracting it, then that is possible using the given command syntax:
7z l Archive-file-Name
5. Export files
If you want all files to be exported to a folder without keeping the folder structure, the following command can be used.
7z e -y ArchivName.7z -o [TargetFolder]
6. Creating an archive – Example highest compression:
Those who want to control the compression level of the file can go for the given 7-zip command syntax.
7z u -mx=9 ArchivName.7z FolderToCompress/*
-mx=9, the number 9 is the level of compression that you can reduce if needed.
7. Create an Archive with a password
Do you want to create a password for the file or folder you are compressing? Then that can be possible as well using 7-zip. Here is the command syntax:
7z a archivefile.7z target-folder -p
Note:
archivefile.7z – It is the file name that you want to use for your compressed folder, replace it with whatever you want with 7z other supported extensions by 7-zip.
Target folder – It is the folder or file on your system that you want to compress or create an archive.