As a software developer or IT professional, you may frequently encounter compressed archives in Linux. These archives can come in various formats, such as 7z, rar, tar.bz2, and tar.gz. Extracting archives is an essential task that enables you to access files and directories within them. In this article, we will explore the most common utilities used to extract archives in Linux.
Command 7z
7z is a file compression format that provides high compression ratios and strong encryption. It is a popular format for creating compressed archives and is supported by many software applications. The 7z utility is a command-line tool that can extract 7z archives in Linux.
To extract a 7z archive, you can use the following command:
7z x archive.7z
The x option tells 7z to extract the archive, and archive.7z is the name of the archive file. You can also specify a directory where the extracted files will be placed by using the -o option, like so:
7z x archive.7z -o /path/to/directory
Command RAR
RAR is a file compression format that is widely used in Windows. However, it is also used in Linux, and there are several utilities that can extract RAR archives. One of the most popular utilities is unrar.
To extract a RAR archive using unrar, you can use the following command:
unrar x archive.rar
The x option tells unrar to extract the archive, and archive.rar is the name of the archive file. You can also specify a directory where the extracted files will be placed by using the -d option, like so:
unrar x archive.rar -d /path/to/directory
Command TAR.BZ2
TAR.BZ2 is a file compression format that combines the Tar and Bzip2 compression algorithms. It is often used for compressing large files or directories. To extract a TAR.BZ2 archive, you can use the following command:
tar xvjf archive.tar.bz2
The x option tells tar to extract the archive, and the v option enables verbose output. The j option tells tar to use Bzip2 compression, and archive.tar.bz2 is the name of the archive file. You can also specify a directory where the extracted files will be placed by using the -C option, like so:
tar xvjf archive.tar.bz2 -C /path/to/directory
Command TAR.GZ
TAR.GZ is a file compression format that combines the Tar and Gzip compression algorithms. It is similar to TAR.BZ2, but it uses the Gzip algorithm instead of Bzip2. To extract a TAR.GZ archive, you can use the following command:
tar xvzf archive.tar.gz
The x option tells tar to extract the archive, and the v option enables verbose output. The z option tells tar to use Gzip compression, and archive.tar.gz is the name of the archive file. You can also specify a directory where the extracted files will be placed by using the -C option, like so:
tar xvzf archive.tar.gz -C /path/to/directory
Conclusion
In this article, we have explored the most common utilities used to extract archives in Linux, including 7z, rar, tar.bz2, and tar.gz. By mastering these utilities, you can quickly and easily extract compressed archives, enabling you to access the files and directories contained within them. While there are many other utilities available for extracting archives in Linux, these four are among the most widely used
📕 Related articles about Linux
- How to Enable Password Authentication in SSH [5 easy steps]
- How to Check SSH Server’s Configuration Validity: A Comprehensive Guide for Software Developers [8 steps]
- How to Show Failed SSH Login
- How to Fix “Remove Host Identification has Changed” Warning in SSH
- How to Check File and Directory Size in Linux
- What is Root Login in SSH