RAR is a most popular tool for creating and extracting compressed archive
(.rar)
files. When we download an archive file from the web, we required a rar tool to extract them.Select all the files and folders inside the compressed file. Or multi-select only the files or folders you want to open by holding the CTRL key and left-clicking on them. Click 1-click Unzip and choose Unzip to PC or Cloud in the WinZip toolbar under the Unzip/Share tab.
RAR is available freely under Windows operating systems to handle compressed files, but unfortunately, rar tool doesn’t pre-installed under Linux systems.
This article explains how to install unrar and rar command-line tools using official binary tar file under Linux systems to open, extract, uncompress or unrar an archive file.
Step 1: How to Install Unrar in Linux
On Debian and Ubuntu based distributions, you can easily install unrar package using the apt-get or apt program as shown.
If you are using Fedora distribution, you can use the dnf command to install it.
If you are using a CentOS / RHEL distribution, you need to download the latest unrar/rar file and install it using following commands.
Step 2: How to Open/Extract a RAR File in Linux
To open/extract a RAR file in current working directory, just use the following command with unrar e option.
To open/extract a RAR file in specific path or destination directory, just use the unrar e option, it will extract all the files in specified destination directory.
To open/extract a RAR file with their original directory structure. just issue below command with unrar x option. It will extract according their folder structure see below output of the command.
Step 3: How to List a RAR File in Linux
To list a files inside a archive file use unrar l option. It will display the list of files with their sizes, date, time and permissions.
Step 4: How to Test a RAR File in Linux
To test an integrity of a archive file, use option unrar t. The below command will perform a complete integrity check for each file and displays the status of the file.
The unrar command is used to extract, list or test archive files only. It has no any option for creating RAR files under Linux. So, here we need to install RAR command-line utility to create archive files.
Step 5: How to Install Rar in Linux
To install RAR command option in Linux, just execute following command.
Sample Output
Step 6: How to Create Rar File in Linux
To create a archive(RAR) file in Linux, run the following command with rar a option. It will create archive file for a tecmint directory.
Step 7: How to Delete files from Archive
To delete a file from a archive file, run the command.
Step 8: How to Recover Archives
To recover or fix a archive file or files, run the command with option rar r.
Step 9: How to Update Archives
To update or add files to existing archive file, use the following command with option rar u.
Now, verify that the file tecmint.sql is added to archive file.
Step 10: How to Set Password to Archives
This is very interesting feature from Rar tool, it allows us to set a password to archive file. To password protect archive file use option rar a -p.
Now verify it by extracting the archive file and see whether it will prompt us to enter password that we have set above.
Step 11: How to Lock Archives
Another interesting lock feature from rar tool, it provides a option to lock a particular archive file from extracting it.
Conclusion
For mor RAR and Unrar options and usage, run the following command it will display a list of options with their description.
We have presented almost all of the options above for rar and unrar commands with their examples. If you feel that we’ve missed anything in this list and you would like us to add, please update us using comment form below.