How to Extract and Create RAR Files with WinRAR on Arch Linux/Manjaro

mail
Cyrus Kao

RAR is a very common format for archiving on Windows. Since Linux system usually prefer tarball, only tar is installed by default. On Arch-based Linux distros (e.g. Manjaro, EndeavourOS, ArcoLinux, BlackArch), we'll be using unrar package for extracting and rar package for both extracting and creating RAR files.

Installation

Install the package depending on your needs.

Both Extracting and Creating

For both extracting and creating RAR files, install rar from AUR:

  • Using pacman

    sudo pacman -S --needed git && git clone https://aur.archlinux.org/rar.git && cd rar && makepkg -si
    Bash
  • Using yay

    yay -S rar
    Bash

Extracting Only

For extracting RAR files only, install unrar from AUR:

  • Using pacman

    sudo pacman -S unrar
    Bash
  • Using yay

    yay -S unrar
    Bash

Usage

Creating/Updating Archives

Create a RAR archive named archive.rar containing the Downloads folder:

rar a archive.rar Downloads
Bash
Creating archive archive.rar

Adding    Downloads/backup-1644905322287.tar.gz            OK
Adding    Downloads/backup-1644816784522.tar.gz            OK
Adding    Downloads/backup-1644737437055.tar.gz            OK
Adding    Downloads/backup-1644990332537.tar.gz            OK
Adding    Downloads/backup-1644906390827.tar.gz            OK
Adding    Downloads/backup-1644754107014.tar.gz            OK
Adding    Downloads                                        OK
Done
Output

If the RAR archive is already existed, then the same command will update its content instead of creating new archive:

rar a archive.rar Downloads
Bash
Updating archive archive.rar

Updating  Downloads/backup-1644905322287.tar.gz            OK
Updating  Downloads/backup-1644816784522.tar.gz            OK
Updating  Downloads/backup-1644737437055.tar.gz            OK
Updating  Downloads/backup-1644990332537.tar.gz            OK
Updating  Downloads/backup-1644906390827.tar.gz            OK
Updating  Downloads/backup-1644754107014.tar.gz            OK
Updating  Downloads                                        OK
Adding    Downloads/backup-1644992010699.tar.gz            OK
Done
Output

And here is the created archive:

archive.rar
archive.rar in GNOME Archive Manager

Extracting Archives

Without Archived Paths

Extract archive.rar without its original directory structure:

unrar e archive.rar
Bash
Extracting from archive.rar

Extracting  backup-1644905322287.tar.gz                               OK
Extracting  backup-1644816784522.tar.gz                               OK
Extracting  backup-1644737437055.tar.gz                               OK
Extracting  backup-1644990332537.tar.gz                               OK
Extracting  backup-1644906390827.tar.gz                               OK
Extracting  backup-1644992010699.tar.gz                               OK
Extracting  backup-1644754107014.tar.gz                               OK
All OK
Output

Extracted files:

File structure
File structure in GNOME Files

With Full Path

Extract with its original directory structure:

unrar x archive.rar
Bash
Extracting from archive.rar

Would you like to replace the existing file Downloads/backup-1644905322287.tar.gz
3130594 bytes, modified on 2022-02-15 14:08
with a new one
3130594 bytes, modified on 2022-02-15 14:08

[Y]es, [N]o, [A]ll, n[E]ver, [R]ename, [Q]uit a

Extracting  Downloads/backup-1644905322287.tar.gz                     OK
Extracting  Downloads/backup-1644816784522.tar.gz                     OK
Extracting  Downloads/backup-1644737437055.tar.gz                     OK
Extracting  Downloads/backup-1644990332537.tar.gz                     OK
Extracting  Downloads/backup-1644906390827.tar.gz                     OK
Extracting  Downloads/backup-1644992010699.tar.gz                     OK
Extracting  Downloads/backup-1644754107014.tar.gz                     OK
All OK
Output

Folder Downloads Extracted then replaced the existing files in the current Downloads directory:

File structure
File structure in GNOME Files

See Also

Comments

0500