We usually associate RAR files with Windows, however more and more people use Ubuntu which makes it necessary to know how to compress and decompress RAR files in Ubuntu.
In case you didn't know, RAR stands for Roshal Archive and is a proprietary format with a lossless compression algorithm. Although RAR is slower than ZIP, it has a higher compression rate and better data redundancy.
Due to licensing issues, an Ubuntu installation does not include packages for RAR files natively.
Open a terminal and install a rar package:
Here is a basic syntax to compress files:
For example:
Sample output:
To add a password to your archive, just add -p
option to the end of your command and you will be prompted to enter a password:
We have to install a package called unrar from the official Ubuntu repositories.
Run the following in your terminal:
Follow this syntax to decompress files in Ubuntu:
Sample output:
If the file is password-protected, you will be prompted immediately.
Congratulations! You have learned how to compress and decompress files from a terminal in your Ubuntu Shell.