
How to Compress a Folder to .7z Archive in Linux/Ubuntu?
Data compression is essential to conserve both storage space as well as bandwidth. There are many archive formats available on Linux/Ubuntu to compress Folders and files, for example, tar, 7z, zip, etc.
7z is one of the popular archive formats as it achieves the highest efficiency by offering the highest compression ratio among other archive formats. Additionally, 7z is a cost-free, open-source, cross-platform archive format offering AES-256 encryption to secure data.
This article will demonstrate four different methods to compress a folder to a 7z archive in Linux/Ubuntu 22.04:
- P7zip Terminal Utility
- P7zip Desktop Utility (GUI)
- Ubuntu’s GUI
- Fireroller Archive Manager
Method 1: How to Compress a Folder to 7z Archive via P7zip Terminal Utility?
P7zip is a 7zip compression utility. It is available in both Terminal and Desktop (GUI) versions. In this section, the compression of a folder via terminal utility is demonstrated while in the following section, folder compression via Desktop version will be demonstrated.
Linux Ubuntu offers three types of p7zip packages
- p7zip: Lighter version of p7zip compression utility.
- P7zip-full: Support more 7z compression algorithms and support audio files.
- P7zip-rar: Other than p7zip-full, p7zip-rar provides support for rar files also.
The User can select the p7zip package according to requirements. To compress a folder “LinuxGenie” to 7z archive “Compressed7zArchive.7z via the p7zip terminal utility, execute the following steps:
Step 1: Updating System Repositories
Launch the Terminal via the keyboard by pressing the combination of [Ctrl + Alt + T] keys:
Then, update system repositories by executing the following command:
$ sudo apt update

Step 2: Install P7Zip Terminal Utility
P7Zip is not pre-installed in Linux/Ubuntu. To install the P7zip utility, execute the following command:
$ sudo apt-get install p7zip-full

Enter “Y” to continue with the installation and the installation will be completed in a few seconds.
Step 3: Compress a Folder to 7z Archive
To compress a folder in 7z archive, execute the following command:
$ 7z a Compressed7zArchive.7z LinuxGenie
The above command comprises of:
- 7z: 7z command line tool
- a: add the folder to the archive
- Compressed7zArchive.7z: name of the archive file.
- LinuxGenie: The Folder to be compressed
From the above image, it can be observed that the Folder “LinuxGenie” is successfully compressed to Compressed7zArchive.7z.
Method 2: How to Compress a Folder to 7z Archive via P7zip Desktop Utility?
P7zip utility comes in both Terminal and desktop (GUI) versions. The P7zip desktop version is useful for users who prefer to work on GUI/Ubuntu UI. In this section, the compression via the p7zip desktop utility is discussed. To compress a folder “LinuxGenie” to “LinuxGenie.7z” archive via the p7zip desktop utility, the following steps are performed:
Step 1: Updating System Repositories
Launch the Terminal via the keyboard by pressing the combination of [Ctrl + Alt + T] keys and update system repositories by executing the following command:
$ sudo apt update

Step 2: Install P7Zip Desktop Utility (GUI)
A snap consists of an app along with all its dependencies. A snap works with many different distributions of Linux. To install the P7zip desktop utility via the snap application, execute the following command:
$ sudo snap install p7zip-desktop

The installation takes a few minutes:
The above output indicates the successful installation of P7Zip Desktop Utility.
Step 3: Create a New Archive
To compress a folder “LinuxGenie” in the “Downloads” directory to 7z archive “LinuxGenie.7z” execute the following steps:
- First, launch P7zip by clicking on the “Applications” button at the bottom left, then type “p7zip” in the search bar and then select the “P7Zip Desktop” icon.
- Navigate to the directory that contains the folder, “LinuxGenie” that needs to be compressed. Then select that folder, followed by pressing the “+” button in the top left corner:
- A pop-up window “Add to Archive” is launched. Add the name of Archive in the, i.e., LinuxGenie.7z in the Archive tab. Then press the “OK” button to compress the “LinuxGenie” folder after selecting the compression parameters such as compression level, compression method, etc.
Step 4: Verify Compression
P7Zip utility saves the compressed archive in the same directory of the folder. Therefore, in order to verify compression via P7zip, navigate to the “Downloads” directory.
From the above image, it can be verified that the folder “LinuxGenie” is successfully compressed to the “LinuxGenie.7z” Archive.
Method 3: How to Compress a Folder to 7z Archive via Ubuntu UI?
The easiest and fastest way to compress a folder to a 7z compressed archive is via Ubuntu UI. To compress a folder “LinuxGenie” in the “Downloads” directory to 7z archive “7zCompressedArchive.7z” via Ubuntu UI, execute the following steps:
Step 1: Create a New Archive
To create a new .7z archive, first, navigate to the directory that contains the folder that needs to be compressed. Then select that folder with either a keyboard or a mouse followed by selecting “Compress” from the right-click drop-down menu:
A “Create Archive” pop-up window is launched. First, type the name of the archive, i.e., “7zCompressedArchive” in the Archive name tab, followed by selecting the “7z” compression technique. Finally, press the “Create” button in the top right corner to initiate the compression process.
Step 2: Verify Compression
To verify compression via Ubuntu UI, navigate to the “Downloads” directory:
From the above image, it can be verified that the folder “LinuxGenie” is successfully compressed to the “7zCompressedArchive.7z” Archive.
Method 4: How to Compress a Folder to 7z Archive via File Roller Archive Manager?
File Roller archive manager is the default file manager for the GNOME desktop environment, thus, there is no need to install “File Roller”. To compress a folder “LinuxGenie” in the “Downloads” directory to 7z archive “Compressed7zArchive.7z” execute the following steps:
Step 1: Launch File Roller Archive Manager
First, launch the “File Roller Archive Manager” by clicking on the “Applications” button at the bottom left, then type “File Roller” in the search bar and then select the “Archive Manager” icon.
Step 2: Create a New Archive
To compress the Folder, first press the “New” button in the top right corner and then select “New Archive” from the drop-down menu:
A “New Archive” pop-up window will appear. First type the name of the archive, i.e., “Compressed7zArchive” in the “Filename” followed by selecting the “.7z” compression method, Then select the location to save the Archive from the “Location” tab followed by pressing the “Create” button to create a new archive:
A “Compressed7zArchive.7z” pop-up window will appear next. Press the “+” button at the top left corner to add the folder to the archive:
To add the folder, first select the path of the folder that needs to be compressed, i.e., “LinuxGenie” from the “Location” tab followed by pressing the “Add” button in the top right corner to initiate the compression process after selecting the LinuxGenie folder.
Step 3: Verify Compression
To verify compression via File Roller, navigate to the “Downloads” directory.
From the above image, it can be verified that the folder “LinuxGenie” is successfully compressed to the “Compressed7zArchive.7z” Archive.
Conclusion
A folder can be compressed to a 7z archive via Terminal as well as GUI utilities. To compress a folder via the P7zip terminal tool, execute the command “7z a <Archive.7z> <Folder>”. Additionally, a folder can be compressed in the 7z archive by GUI utilities such as P7zip, Ubuntu UI, and File Roller. This article demonstrated four ways to compress a folder to a 7z archive in Linux/Ubuntu 22.04.