rar is a popular file archiving format where WinRAR is typically used to create and extract rar files in Microsoft Windows environment.

Linux users can use unrar to view and extract rar archive files. It’s a command-line utility that and is not installed by default in most Linux distributions.

You can both install and use unrar from the terminal in Linux.

Steps to view and extract rar archive in Linux:

  1. Launch your preferred terminal application.
  2. Check if the rar file is of correct format.

    $ file archive.rar archive.rar: RAR archive data, v5

  3. Install unrar program for your Linux distribution.

    sudo apt update && sudo apt install --assume-yes unrar #Ubuntu and Debian

  4. View content of rar file without extracting.

    $ unrar l archive.rar  UNRAR 5.61 beta 1 freeware      Copyright (c) 1993-2018 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

  5. Create a temporary directory to extract the rar archive.

    $ mkdir temp

  6. Ensure you have enough disk space to extract the file.

    $ df -h temp/ Filesystem      Size  Used Avail Use% Mounted on /dev/sda2        20G  4.3G   15G  23% /

  7. Extract your rar archive using unrar to the newly created directory.

    $ unrar x archive.rar temp/  UNRAR 5.61 beta 1 freeware      Copyright (c) 1993-2018 Alexander Roshal   Extracting from archive.rar  Creating    temp/archive                                              OK Creating    temp/archive/folder-02                                    OK Extracting  temp/archive/folder-02/file-02                            OK Extracting  temp/archive/folder-02/file-01                            OK Creating    temp/archive/folder-01                                    OK Extracting  temp/archive/folder-01/file-02                            OK Extracting  temp/archive/folder-01/file-01                            OK All OK

    Other options for unrar command:

    UNRAR 5.61 beta 1 freeware      Copyright (c) 1993-2018 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  <Switches>   -             Stop switches scanning   @[+]          Disable [enable] file lists   ad            Append archive name to destination path   ag[format]    Generate archive name using the current date   ai            Ignore file attributes   ap<path>      Set path inside archive   c-            Disable comments show   cfg-          Disable read configuration   cl            Convert names to lower case   cu            Convert names to upper case   dh            Open shared files   ep            Exclude paths from names   ep3           Expand paths to full including the drive letter   f             Freshen files   id[c,d,p,q]   Disable messages   ierr          Send all messages to stderr   inul          Disable all messages   kb            Keep broken extracted files   n<file>       Additionally filter included files   [email protected]            Read additional filter masks from stdin   [email protected]<list>      Read additional filter masks from list file   o[+|-]        Set the overwrite mode   ol[a]         Process symbolic links as the link [absolute paths]   or            Rename files automatically   ow            Save or restore file owner and group   p[password]   Set password   p-            Do not query password   r             Recurse subdirectories   sc<chr>[obj]  Specify the character set   sl<size>      Process files with size less than specified   sm<size>      Process files with size more than specified   ta<date>      Process files modified after <date> in YYYYMMDDHHMMSS format   tb<date>      Process files modified before <date> in YYYYMMDDHHMMSS format   tn<time>      Process files newer than <time>   to<time>      Process files older than <time>   ts[m|c|a]     Save or restore file time (modification, creation, access)   u             Update files   v             List all volumes   ver[n]        File version control   vp            Pause before each volume   x<file>       Exclude specified file   [email protected]            Read file names to exclude from stdin   [email protected]<list>      Exclude files listed in specified list file   y             Assume Yes on all queries

  8. List extracted files.

    $ ls -R temp/ temp/: archive  temp/archive: folder-01  folder-02  temp/archive/folder-01: file-01  file-02  temp/archive/folder-02: file-01  file-02