Install UNRAR on Ubuntu 20.04 LTS

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 Ubuntu, but it is available to install from its repository.

The following tutorial will show you how to install UNRAR on Ubuntu 20.04 LTS Desktop or Server, along with the most commonly used commands.

Prerequisites

  • Recommended OS: Ubuntu 20.04.
  • User account: A user account with sudo or root access.

Update Operating System

Update your Ubuntu 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@ubuntu ~]$ sudo whoami
root

To set up an existing or new sudo account, visit our tutorial on How to Add a User to Sudoers on Ubuntu.

To use the root account, use the following command with the root password to log in.

su

The tutorial will utilize the terminal interface, which can be found in the show applications menu.

Example:

Install UNRAR on Ubuntu 20.04 LTS

Install UNRAR on Ubuntu

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 Ubuntu 20.04’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 Ubuntu

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:

Install UNRAR on Ubuntu 20.04 LTS

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, followed 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 Ubuntu 20.04 LTS 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.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!