In this tutorial, we will show you how to install 7Zip on Ubuntu 20.04 LTS. For users managing files on Ubuntu, 7-Zip stands out as a powerful and versatile archiving tool. 7-Zip is renowned for its high compression ratio and broad format support, making it essential for handling various archive types, including 7z, ZIP, TAR, GZIP, and more. This guide provides detailed, step-by-step instructions on how to install 7-Zip on Ubuntu 20.04 LTS. Whether you’re a beginner or an experienced Linux user, this tutorial will walk you through different installation methods, ensuring you can effectively compress, extract, and manage your files.
Why Use 7-Zip?
7-Zip offers several advantages over other archiving tools. Its superior compression capabilities reduce file sizes significantly, saving storage space and bandwidth when sharing files. Additionally, 7-Zip supports a wide array of archive formats, ensuring compatibility with virtually any archive you encounter. Moving large files and folders is a breeze with this method, while the program also boasts strong encryption features that protect sensitive data.
Prerequisites
Before proceeding with the installation, ensure the following prerequisites are met:
- Ubuntu 20.04 LTS: A properly configured Ubuntu 20.04 LTS system is required.
- Sudo Privileges: You need a user account with
sudo
privileges to install software. - Internet Connection: An active internet connection is necessary to download the required packages.
To log in as a non-root user with sudo privileges, use the following command:
su - username
Replace “username” with your actual username. After logging in, you can use sudo
before commands that require administrative rights.
Methods to Install 7-Zip on Ubuntu 20.04
There are multiple ways to install 7-Zip on Ubuntu 20.04, each catering to different preferences and needs:
- APT (Advanced Package Tool): Installing from the Ubuntu repository using
apt
is the simplest and most common method. - Snap Package Manager: Installing via
snap
provides a sandboxed environment. - Official Website: Downloading and installing the binary from the 7-Zip official website gives you the latest version.
- Wine: Using Wine to install the Windows version allows you to use the GUI (Graphical User Interface).
Method 1: Installing 7-Zip from the Ubuntu Repository
The easiest way to install 7-Zip is through the Ubuntu repository using the apt
package manager. This method ensures you get a stable and compatible version of 7-Zip. By updating the package list, you get the most recent versions.
Updating the Package List
Before installing any new software, it’s crucial to update the package list. This ensures you have the latest information about available packages and their dependencies. Use the following command:
sudo apt update
This command retrieves package information from all configured sources. It updates the local package index, allowing apt
to find the newest versions of packages.
Installing the p7zip-full
Package
The p7zip-full
package provides the command-line version of 7-Zip. To install it, run:
sudo apt install p7zip-full
This command downloads and installs the p7zip-full
package along with any required dependencies. Once the installation is complete, you can use 7-Zip from the command line.
Installing p7zip-rar
Package (Optional)
If you need to work with RAR archives, you should also install the p7zip-rar
package. This adds support for RAR files to 7-Zip. Execute the following command:
sudo apt install p7zip-rar
This command installs the necessary components to handle RAR archives, allowing 7-Zip to extract and compress RAR files.
Verifying the Installation
To verify that 7-Zip is installed correctly, use the following command:
7z
If 7-Zip is installed correctly, this command will display the 7-Zip help information, showing the available commands and options. This confirms that 7-Zip is accessible from your terminal.
Method 2: Installing 7-Zip with SNAP
Snap is a universal package manager that simplifies software installation across different Linux distributions. It provides a sandboxed environment for applications, enhancing security and stability.
Introduction to SNAP
SNAP comes pre-installed on modern Ubuntu systems, making it a convenient option for installing software. It packages applications with all their dependencies, ensuring they run consistently across different environments.
Installing p7zip-desktop
To install the GUI version of 7-Zip using SNAP, run the following command:
sudo snap install p7zip-desktop
This command downloads and installs the p7zip-desktop
snap package, providing a graphical interface for 7-Zip.
Running p7Zip GUI
After installation, you can launch the p7Zip GUI from the applications menu. Search for “p7Zip” or “7-Zip” in the application launcher and click the icon to start the program.
The user interface is straightforward, with options to browse files, create archives, and extract files from existing archives. The GUI provides a user-friendly way to interact with 7-Zip.
Using 7Zip to Compress Files
To compress files using the GUI, follow these steps:
- Navigate to the File: Use the file browser to locate the files or folders you want to compress.
- Add to Archive: Select the files, right-click, and choose “Add to archive.”
- Set Compression Options: In the “Add to Archive” dialog, you can set various compression options, such as:
- Archive Format: Choose the archive format (e.g., 7z, ZIP, TAR).
- Compression Level: Select the compression level (e.g., Store, Fastest, Fast, Normal, Maximum, Ultra). Higher compression levels result in smaller files but take longer to compress.
- Encryption: Set a password to encrypt the archive, protecting its contents.
- Start Compression: Click “OK” to start the compression process.
Method 3: Installing the Latest Version from the Official 7-Zip Website
For users who prefer to have the absolute latest version of 7-Zip, installing directly from the official website is the best option. However, this method can be more complex since it requires manual steps.
Downloading the Binary Archive
To download the latest version of 7-Zip, visit the official 7-Zip website. Find the download section for Linux and identify the correct version for your system (32-bit or 64-bit).
Once you’ve identified the correct version, use wget
to download the archive. For example:
wget https://www.7-zip.org/a/7z2301-linux-x64.tar.xz
Note: Replace the URL with the actual link to the latest version available on the 7-Zip website. The version number in the command may need to be adjusted to match the downloaded version.
Extracting the Archive
After downloading the archive, you need to extract its contents. First, create a directory for the extracted files:
mkdir 7zip
Then, extract the archive to the newly created directory:
tar xf 7z2301-linux-x64.tar.xz -C 7zip
Note: Adjust the filename in the command to match the downloaded version. This command extracts the contents of the archive to the 7zip
directory.
Running the 7-Zip Binary
To run the 7-Zip binary, navigate to the extracted directory:
cd 7zip
Then, execute the 7-Zip binary:
./7zz
If you run the binary from a different directory, you need to provide the full path to the binary. This command launches the 7-Zip command-line interface.
Making 7-Zip Accessible System-Wide (Optional)
To make 7-Zip accessible from any location in the terminal, you can move the extracted directory to a system-wide location:
sudo mv ~/7zip /usr/local/bin
This command moves the 7zip
directory to /usr/local/bin
, making the 7-Zip executable accessible from any terminal session. This is a convenience, not a necessity.
Method 4: Installing 7-Zip GUI Using Wine
Since 7-Zip is primarily a Windows application, you can use Wine, a compatibility layer, to run the Windows version on Ubuntu. This method provides the full graphical interface of 7-Zip.
Introduction to Wine
Wine allows you to run Windows applications on Linux by providing a Windows-compatible environment. It translates Windows system calls into equivalent Linux system calls, enabling Windows applications to run seamlessly.
Installing Wine
First, enable 32-bit architecture:
sudo dpkg --add-architecture i386
Next, add the Wine repository:
wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add -
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'
Note: Ensure the correct Ubuntu version is specified in the repository URL. Then, install Wine:
sudo apt update && sudo apt install --install-recommends winehq-stable
This command installs the stable version of Wine along with recommended dependencies.
Installing 7-Zip
Visit the official 7-Zip download page and download the Windows .exe
version. Ensure you download the correct version (32-bit or 64-bit) for your system.
To run the installer using Wine, use the following command:
wine 7z2101-x64.exe
Note: Adjust the filename to match the downloaded version. This command launches the 7-Zip installation wizard within the Wine environment.
Running 7-Zip
After installation, you can find and launch 7-Zip from the applications menu. It will appear as a Windows application running within Wine.
Basic Usage of 7-Zip (Command Line)
The command-line interface of 7-Zip provides powerful options for compressing and extracting files. Here are some basic commands.
Compressing Files and Directories
To compress files and directories into a 7z archive, use the following syntax:
7z a archive.7z file1 file2 directory
For example, to compress file1.txt
, file2.txt
, and the directory mydir
into archive.7z
, run:
7z a archive.7z file1.txt file2.txt mydir
Extracting Files from an Archive
To extract files from an archive, use the following syntax:
7z x archive.7z
This command extracts files with full paths. To extract files to the current directory, use the e
option:
7z e archive.7z
The x
option preserves the directory structure within the archive, while the e
option extracts all files to the current directory.
Listing Archive Contents
To list the contents of an archive, use the following command:
7z l archive.7z
This command displays a list of files and directories within the archive, along with their sizes and modification dates.
Uninstalling 7-Zip
If you no longer need 7-Zip, you can remove it from your system using the appropriate method based on how you installed it.
If Installed via apt
To remove 7-Zip installed via apt
, use the following command:
sudo apt remove p7zip-full p7zip-rar
If Installed via snap
To remove 7-Zip installed via snap
, use the following command:
sudo snap remove p7zip-desktop
If Installed from Binary
If you installed 7-Zip from the binary, manually remove the files and directories you created during the installation. For example:
sudo rm -r /usr/local/bin/7zip
If Installed via Wine
To uninstall 7-Zip installed via Wine, use the Wine uninstaller. Open the Wine configuration and navigate to the “Applications” tab. Select 7-Zip from the list and click “Remove.”
Congratulations! You have successfully installed 7-Zip. Thanks for using this tutorial for installing the 7-Zip File Archiver on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official 7-Zip website.