RAR archives on Linux

To create and unpack RAR archives in the Linux Ubuntu operating system, you must type the package installation command in the terminal:

sudo apt-get install rar unrar

Then in Ubuntu with a graphical interface it will be possible to perform manipulations with archives and files that need to be packed or unpacked by right-clicking.

I will give examples of operations through the command line:

Unzip the archive:

rar e archive.rar dir

Archive the directory and set the password for the archive:

rar dir -pPASSWORD archive.rar

Unzip archive with password:

rar e -pPASSWORD archive.rar dir

Unzip the archive with the password via unrar (the password must be entered after entering the command):

unrar x archive.rar

Simple directory archiving:

rar dir archive.rar

An example of creating a rar archive with a password through the command line:

sudo rar a -m2 -r -hp name.rar /home/backups/now/*

Archiving multiple objects:

sudo rar a -m2 -r -hp name.rar /home/backups/now/* /home/backups/dir2/* file1 file2

a (means adding files)
-m2 (compression ratio from 0 to 5)
-r (add recovery information)
-hp (setting a password, you must enter it twice when executing the command)
-t (archive testing)
-r (restore archive)

See also my article:
RAR and ZIP archiving on Linux

Leave a comment

Leave a Reply