UNRAR is widely known and used amongst Windows users. RAR files are much smaller archives and compress better than ZIP for most files by compressing files “together,” saving more space. UNRAR does not come pre-installed natively on Debian, but it is available to install from its repository.
The following tutorial will show you how to install UNRAR on Debian 11 Bullseye and the basic commands to use it on either your Debian desktop or server.
Table of Contents
Prerequisites
- Recommended OS: Debian 11 Bullseye.
- User account: A user account with sudo or root access.
Update Operating System
Update your Debian operating system to make sure all existing packages are up to date:
sudo apt update && sudo apt upgrade -y
The tutorial will be using the sudo command and assuming you have sudo status.
To verify sudo status on your account:
sudo whoami
Example output showing sudo status:
[joshua@debian~]$ sudo whoami
root
To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Debian.
To use the root account, use the following command with the root password to log in.
su
The tutorial will utilize the terminal for the installation found in Activities > Show Applications > Terminal.
Example:
Install UNRAR on Debian
The first step is to install the UNRAR application. For this, you do not need to add any additional third-party repositories as it is present in Debian 11’s default repository.
In your terminal, use the following command.
sudo apt install unrar-free
Example output:
Type Y, then press the ENTER KEY to proceed.
Lastly, verify the version installed to make sure the installation was successful.
unrar --version
Example output:
unrar 0.0.1
How to Use UNRAR on Debian
Below are some basic commands and examples of using UNRAR. While they do not show everything possible, they cover 75% of what most users would use UNRAR for regularly.
The first command that is most helpful before the tutorial continues further is the help command.
unrar --help
Example output:
Extract a RAR Archive Current Directory
To extract or open a RAR file in a current directory, use the unrar -x command.
unrar -x {file-name}.rar
Alternative:
unrar --extract {file-name}.rar
Extract a RAR Archive to Folder
To extract or open a RAR file that needs a specific path or destination directory, use the following unrar -x command again following by the full path of the final destination.
unrar -x {file-name}.rar /media/photos/
Alternative:
unrar --extract {file-name}.rar /media/photos/
Extract Only New Files from a RAR Archive
To extract a RAR archive and only pull the new files, use the following command.
unrar --extract-newer {filename}.rar
Extract RAR Archive with No Path Creations
To extract a RAR archive and not create all the subdirectories paths and keep all the files centralized in one directory, use the following command.
unrar --extract-no-paths {filename}.rar
Extract a RAR Archive and Overwrite Existing Files
To extract a RAR archive and overwrite any existing files with the same filenames, use the following command.
unrar -f {filename}.rar
Alternative:
unrar --force {filename}.rar
Extract a Password Protected RAR Archive
To extract a password-protected RAR archive, use the following command.
unrar -p {filename}.rar
Alternative:
unrar --password {filename}.rar
List a RAR File
To list the files in a RAR file, use the following unrar -t command.
unrar -t {filename}.rar
Alternative:
unrar --list {filename}.rar
Comments and Conclusion
In the tutorial, you have learned how to install UNRAR on Debian 11 Bullseye and use the most common commands. Overall, UNRAR is an excellent option for constant use of extensive archives that need compressing, especially if working between multiple operating systems such as Windows or macOS.