RAR files are compressed archives commonly used to bundle multiple files into one. While the RAR format is proprietary, Linux users can extract RAR files using the command-line tool unrar. This tool is available across most Linux distributions and offers a simple way to manage RAR archives.
Installing unrar on Linux is straightforward since it is included in the default repositories of many distributions. The tool allows you to inspect and extract the contents of a RAR archive directly from the terminal. For systems where unrar is not available, an alternative called unar can be used.
Once installed, unrar provides essential functions like previewing contents and extracting files to a specific location. This process is efficient and can be performed entirely through the terminal, making it ideal for users comfortable with command-line operations.
Steps to extract RAR files on Linux:
- Open the terminal on your Linux system.
- Confirm the RAR file format using the file command.
$ file archive.rar archive.rar: RAR archive data, v5
- Install the unrar package from your distribution’s package manager.
$ sudo apt update && sudo apt install --assume-yes unrar # Ubuntu and Debian [sudo] password for user: ##### snipped The following NEW packages will be installed: unrar 0 upgraded, 1 newly installed, 0 to remove, and 0 not upgraded. Need to get 113 kB of archives. After this operation, 400 kB of additional disk space will be used. ##### snipped
$ sudo yum install --assumeyes epel-release && sudo yum install --assumeyes unar # CentOS 7 and other Red Hat variance [sudo] password for user:
The package name and the corresponding binary is unar instead of unrar. This is also only available for CentOS / Red Hat 7 or below.
> sudo zypper refresh && sudo zypper -n install unrar #OpenSUSE and other SUSE variance [sudo] password for root: d Repository 'Main Repository (NON-OSS)' is up to date. Repository 'Main Repository (OSS)' is up to date. Repository 'Main Update Repository' is up to date. All repositories have been refreshed. Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW package is going to be installed: unrar 1 new package to install. Overall download size: 155.3 KiB. Already cached: 0 B. After the operation, additional 334.1 KiB will be used. Continue? [y/n/v/...? shows all options] (y): y
- Preview the contents of the RAR file before extraction.
$ unrar l archive.rar UNRAR 5.71 freeware Copyright (c) 1993-2019 Alexander Roshal Archive: archive.rar Details: RAR 5 Attributes Size Date Time Name ----------- --------- ---------- ----- ---- -rw-rw-r-- 0 2019-11-02 01:41 archive/folder-02/file-02 -rw-rw-r-- 0 2019-11-02 01:41 archive/folder-02/file-01 -rw-rw-r-- 0 2019-11-02 01:41 archive/folder-01/file-02 -rw-rw-r-- 0 2019-11-02 01:41 archive/folder-01/file-01 drwxrwxr-x 0 2019-11-02 01:41 archive/folder-02 drwxrwxr-x 0 2019-11-02 01:41 archive/folder-01 drwxrwxr-x 0 2019-11-02 01:41 archive ----------- --------- ---------- ----- ---- 0 7
- Ensure there is sufficient disk space available for the extraction.
$ df -h temp/ Filesystem Size Used Avail Use% Mounted on /dev/sda2 20G 4.3G 15G 23% /
- Create a directory to store the extracted files (optional).
$ mkdir directory
- Navigate to the directory where you want to extract the files.
$ cd directory
- Extract the files from the RAR archive.
$ unrar x ~/file.rar UNRAR 5.71 freeware Copyright (c) 1993-2019 Alexander Roshal Extracting from /home/user/file.rar Creating folder OK Creating folder/sub-01 OK Extracting folder/sub-01/file-01 OK Extracting folder/sub-01/file-02 OK All OK
The x option extracts the RAR file and preserves the directory structure.
Other unrar options.
$ unrar UNRAR 5.71 freeware Copyright (c) 1993-2019 Alexander Roshal Usage: unrar <command> -<switch 1> -<switch N> <archive> <files...> <@listfiles...> <path_to_extract\> <Commands> e Extract files without archived paths l[t[a],b] List archive contents [technical[all], bare] p Print file to stdout t Test archive files v[t[a],b] Verbosely list archive contents [technical[all],bare] x Extract files with full path
- Verify the extracted files and browse through the directory contents.
$ ls -R .: folder ./folder: sub-01 ./folder/sub-01: file-01 file-02

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.