#TIL : Compressing and Extracting files with rar in Linux

zip and tar disadvantages

All unicode filename will be transform to weird character, so it makes broken paths and broken links

Notice

rar and unrar in Linux isn’t same version and so don’t use unrar to extract archived file by rar (It causes invalid full paths)

Installation

Ubuntu :

1
$ sudo apt install rar

Redhat ( using RPMForge )

1
$ sudo yum install rar

Compressing files, folder

Compressing files

1
$ rar a result.rar file1 file2 file3 fileN

Compressing dir and its subdirs (remember with trailing slash in the end)

1
$ rar a -r result.rar folder1/

Locking RAR file with password (adding -p"THE_PASSWORD_YOU_WANT")

1
2
$ rar a -p"[email protected]" result.rar file1 file2 file3 fileN
$ rar a -p"[email protected]" -r result.rar folder1/

Extracting file

Listing content of RAR file

1
$ rar l result.rar

Extracting RAR file to current dir

1
$ rar e result.rar

Extracting RAR file to current dir with fullpath

1
$ rar x result.rar

WANT MORE ?

Asking it !

1
$ rar -?

BONUS

WHAT IF I TOLD U THAT A RAR FILE BIGGER 35 TIMES THAN ITS ORIGINAL FILE ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$  echo 'a' > a.txt
$ rar a a.rar a.txt

RAR 3.80 Copyright (c) 1993-2008 Alexander Roshal 16 Sep 2008
Shareware version Type RAR -? for help

Evaluation copy. Please register.

Creating archive a.rar

Adding a.txt OK
Done
$ ls -al
total 72
-rw-r--r-- 1 root root 77 May 17 14:18 a.rar
-rw-r--r-- 1 root root 2 May 17 14:17 a.txt

bus rar

Comments