Here are the steps to create a rar file in linux.
Install a rar package by the following command
$ sudo apt-get install rar
After that just typed the command to create a rar archive of a file or directory
$ sudo rar a filename.rar input
filename.rar is the output file.
input is nothing but a directory.