How to extract rar file in Linux
rar is a proprietary file format for file archival and developed by WinRAR. It provides Winrar to extract rar files in Windows and unrar for Linux.
unrar for Linux is just a command-line tool, unlike WinRar. unrar is also available for other Unix-based operating systems such as macOS and FreeBSD.
unrar is available in most Linux distributions' default package manager's repository and can be installed and used from the terminal.
Steps to extract rar file in Linux:
Launch your preferred terminal application.
Install unrar tool using your Linux distributions' 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
Create folder where you want to extract the file onto (optional).
$ mkdir directory
Go to the target directory where you want to extract the file onto (optional).
$ cd directory
Extract using unrar command.
$ unrar x ~/file.rar UNRAR 5.61 beta 1 freeware Copyright (c) 1993-2018 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
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
View content of extracted file.
$ ls -R .: folder ./folder: sub-01 ./folder/sub-01: file-01 file-02