Command to Install UNRAR in Ubuntu 22.04 or 20.04

UNRAR is a free command utility (GPL licensed) on Linux systems for decompressing and extracting files that are compressed and archived in the RAR archive format. RAR is a popular archive format that is proprietary but commonly and widely used to compress large files. So, that users can share or transfer them easily.

Whereas, if you are a Linux user and got some files that are in RAR format then can easily unpack them using UNRAR tool. This is particularly useful for users who work with large files and need a reliable and efficient way to extract and manage RAR archives on their Ubuntu operating system.

So, if you want to install UNRAR on Ubuntu 22.04 or 20.04 Linux is not a Sisyphean task we just need an internet connection and terminal access.

UNRAR installation on Ubuntu 22.04 or 20.04 Linux

The commands we are using here to set up and use UNRAR command line tool on Ubuntu 22.04 0r 20.04, are not just limited to these versions; users can follow them for older or newer ones as well. Including Debian, Linux Mint, MX Linux, POP OS, and more similar distros.

1. Check for UNRAR is installed or not

Well, maybe UNRAR is already on your Ubuntu Linux system but you don’t know. So, let’s first check the availability of this tool using the command terminal.

To open Terminal, we can use the keyboard shortcut i.e Ctrl+Alt+T, or search Terminal in the Applications. However, the CLI server users will already be on the Terminal, so just run the given command.

unrar -v

If the UNRAR is on your system, then the above command will give you the details of its installed version. Whereas, if it is not there then the system will give a message that the “command ‘unrar’ not found, but can be installed with:“.

check unrar is installed

2. Install UNRAR on Ubuntu 22.04 or 20.04 Linux

So, in our case UNRAR was not installed already, therefore, we can use the APT package manager to install it on our Ubuntu system. However, before that once run the system update command. This will refresh the package index cache of the APT.

sudo apt update

Now, run the installation command:

sudo apt install unrar

Press ‘Y‘ to give you permission to install it and then press the Enter key.

Once the installation is completed you can check the unrar version on Linux to confirm its presence on your system using:

unrar -v
Check Unrar version

3.  Commands to use with Unrar

Once you have the UNRAR installed on your Ubuntu Linux, here are the commands that we can use to extract, decompress, or manage RAR-based archives.

Note: Unrar only extracts the archive, if you want to create a RAR-based archive then you have to install ‘rar‘ tool using sudo apt install rar.

1. Extract files without archived paths using UNRAR

Suppose you have a file name “myfile.rar” and you want to extract its all files from the RAR archive into the current directory. Then the command will be:

unrar e myfile.rar

The “e” option stands for “extract”.

Note: Replace myfile.rar with your filename. Also, if you don’t want to extract all the files in your current folder but instead inside a folder then go for the next command.

Extract Archive using UNRAR in current directory

2. Extract with full path

To extracts all files and directories from the RAR archive let’s say, a file name –  “myfile.rar” while preserving the original directory structure. The “x” option stands for “extract with full path” will be used.

unrar x myfile.rar
Extract RAR file with full path

3. Password Protected RAR files

If you have the RAR file that is password protected then use the -p switch with the regular x option to extract the file:

unrar x p myfile.rar

4. List of the files inside a RAR archive

Displays a list of the files contained in the RAR archive but without extracting them. The “l” option stands for “list”.

unrar l myfile.rar
List of the files inside a RAR archive

5. Display detailed files info present inside the RAR archive

Displays detailed information about the files contained in the RAR archive including file attributes, file size, compression ratio, date time, checksum, and file name. The “v” option stands for “verbose”.

unrar v myfile.rar
Display detailed files info present inside the RAR archive

6. Tests the integrity of the RAR archive

To perform an integrity test before exacting a file using Unrar command for checking any errors or corruption we can use the option “t” option that stands for “test“.

unrar t myfile.rar
Tests the integrity of the RAR archive

Uninstallation

Because of some reason, if you want to remove small size UNRAR tool from your Ubuntu 22.04 or 20.04 Linux then use:

sudo apt remove unrar

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.