Just like with ZIP, RAR is another format to compress and create archive files on a PC or laptop. This process compresses the data and reduces storage space. RAR (.rar) is one of the common formats of compressing files, hence if you are on Debian 11 or 10 and want to use unrar to extract some RAR format archive file downloaded from the web then here are the steps to follow.
Unrar is the tool available in the Debian Base repository for the extraction of compressed archive (.rar) files. Well, we need to install it manually because Unrar is not pre-installed on the Linux systems.
Here we learn not only the method to install Unrar on Debian 11 or 10 but also how to use its command line to extract or uncompress a RAR archive file.
Install and use Unrar on Debian 11 or 10 Linux to extract RAR files
Step 1: Apt update
Run the system update command to refresh the system APT cache and also to install if there are any updates available for your system.
sudo apt update
Step 2: Command to install Unrar in Debian 11 or 10
As I said in the introduction, Unrar is available via the default base repository of Debian Linux, hence just use the APT package manager to fetch its packages and install them using the given command:
sudo apt install unrar-free
Step 3: Unrar options to use
Once the installation is completed we can see what are the options available to use with this command-line tool. For that use the help parameter.
unrar --help
Here is the output:
Usage: unrar [OPTION...] ARCHIVE [FILE...] [DESTINATION] Extract files from rar archives. -x, --extract Extract files from archive (default) -t, --list List files in archive -f, --force Overwrite files when extracting --extract-newer Only extract newer files from the archive --extract-no-paths Don't create directories while extracting -p, --password Decrypt archive using a password -?, --help Give this help list --usage Give a short usage message -V, --version Print program version
Step 4: Extract a RAR File using Unrar on Debian Linux
Next, we learn if we already have some .rar
file then how to use Unrar to extract or uncompress the same using command line:
unrar -x filename.rar
Replace the filename.rar with the actual RAR file that you want to extract.
For example:
I have a file called sample.rar in the Downloads folder, then first I will switch to the Downloads folder.
cd Downloads
And then to list the files available there, we can use:
ls
Now, to extract, simply use Unrar with either x or e option along with the filename.
unrar -x sample.rar
or
unrar -e sample.rar
Step 5: To List the RAR file content
Before extracting the content of some RAR compressed files using Unrar on Linux, we can list all the available folders and files inside it directly on our command terminal. For that use -t
option.
unrar -t filename.rar
Example
unrar -t sample.rar
Step 6: To extract the RAR file in another folder
If you don’t want to extract the RAR file content in the same directory where it exists then we can mention some other directory for it.
For example, let’s create a directory called: Test
mkdir test
Now, extract rar content in the Test folder.
unrar -x filename.rar /path-of-foler
Example:
unrar -x sample.rar ~/Downloads/test/
Step 7: Unrar or uncompress some password protected RAR file
Well, there are many times when we get a password-protected RAR file from the web or over email. Use -p
option.
Syntax:
unrar -x -p filename.rar
Example
unrar -x -p pass-sample.rar
Enter the password.
Other Articles:
• How to Upgrade Debian 10 Buster to 11 Bullseye Linux
• Linux Zip Commands to Archive or Unarchive files
• Install WPS Office on Debian 11 Bullseye