Compression

How to Extract Compressed Archive Files in Linux

This article will list command line methods to extract various compressed archive file formats in Linux. These archives can include single or multiple files and folders, usually compressed to save disk space. Archive file formats are also used for splitting humongous files that can run into GBs. They also make file operations much easier as you must handle a single file or small number of split files only instead of handling many scattered files. Many algorithms for bundling, archiving, and compressing files exist, and this article will explain command line methods to decompress archives made using such algorithms.

GUI Method (Stock Ubuntu with GNOME SHELL)

Ubuntu comes with decompression support for limited compressed archive file formats – mainly zip files, tar archives, and 7z files. To enable full support for other major archive formats, you must install a few extra apps. Run the command below to do so:

$ sudo apt install zip unzip rar unrar p7zip-full

Now you can double click or right click on any compressed archive in the Nautilus file manager to extract files.

The archive manager in Nautilus file manager also includes support for extracting password protected files, so you don’t need any extra apps to extract encrypted archives.

File managers in other desktop environments also have support for extracting archives via plugin systems. You must either install an app named “archive manager” or “file-roller” to add support for extracting files from archives.

7z

7z is one of the most widely used compressed archive file formats. It can deep compress files at a much better ratio than other popular archive formats like zip and rar.

To enable 7z archive support on Ubuntu, run the command below:

$ sudo apt install p7zip-full

To extract a 7z archive to a new directory named same as the archive name, run the command below:

$ 7z x archive.7z

The command above can also be used for password protected 7z archives. You will be prompted to enter a password after running the command above.

Zip

Zip archive is another most widely used file format used for archiving and compression purposes. It is the primary archive file format supported on Windows and ships by default on all major versions of Windows.

To enable zip archive support on Ubuntu, run the command below:

$ sudo apt install zip unzip

To extract a zip archive to a new directory named same as the archive name, run the command below:

$ unzip archive.zip

Like 7z command, unzip command can also be used to extract password protected files. Users will be prompted to enter the password after running the command mentioned above.

Rar

Rar file format is a proprietary archiving and compression format. The support for rar files on Linux is not as robust as other archive file formats but is enough for doing simple compression and decompression tasks.

To add rar archive support on your Ubuntu installation, run the command below:

$ sudo apt install rar unrar

To decompress a regular or password protected rar archive, run the command below:

$ unrar x archive.rar

Tar, Tar.gz, Tar.xz, Tar.bz2, Tgz, Gz

Tar archive file format is available by default on almost all Linux and Unix based operating systems. By default, tar archives are not compressed, you must use additional compression algorithms like gz, bz2 and so on. To extract a tar file, run the command below:

$ tar xf archive.tar

You can replace “archive.tar” in the command above with the correct archive name and file extension. Tar archives don’t have built-in support for encryption, so you can’t use password protection.

Conclusion

These are various command line utilities to extract archive file formats. The tar file format is widely used for distributing software and large files on Linux, though it natively doesn’t support password protection. Other file formats, like zip, rar, and 7z, do support password protection, but they are easier to crack than other encryption methods like GPG (GNU Privacy Guard).

About the author

Nitesh Kumar

Nitesh Kumar

I am a freelancer software developer and content writer who loves Linux, open source software and the free software community.