RAR is a file format used for data compression and archiving. The command was developed by Eugene Roshal and is used to create compressed files. The RAR format supports data compression, error recovery and file spanning. It supports files larger than 4 gigabytes. RAR files can only be created through commercial software. You can unpack them using the free unRAR command line tool in Linux.
For Linux and UNIX distributions unRAR command is used. By default, unRAR is not being installed on Linux or UNIX distro. You need to install unRAR command with the help of yum command.
Install RAR tool.
If you are using Redhat Linux or Centos, then use yum command as follows to install unRAR command.
#yum install unrar
The unRAR command supports various options, below are common options that you need to for extracting files. Listed below are few examples of RAR and unRAR command.
1. RAR a single file.
#rar a log-cups.rar /var/log/log-cups
RAR 3.90 beta 2 Copyright (c) 1993-2009
Alexander Roshal 3 Jun 2009
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive syslog.rar
Adding /var/log/syslog OK
2. RAR multiple files.
Compress ‘file1′, ‘file2′ and ‘file3′ simultaneously,
#rar a file1.rar file1 file2 file3
You can also use the following method to RAR multiple files.
#rar a -r file1.rar file1 file2 file3
3. unRAR compressed file.
#unrar e file1.rar
4. List the content of a RAR file without extracting the file.
#unrar l file1.rar
5. Extract files with full path.
#unrar x file1.rar
6. Check the integrity of archive file.
#unrar t file1.rar
7. Create a password protected RAR file.
While archiving, you can encrypt files with the password (using -p option). If you omit the password on the command line, you will be prompted with message “enter password” and password is case sensitive.
#rar a -pQAZWSX backup '*.txt'