Use the following command to install unrar:
sudo install -c -o $USER unrar /bin
$USER is a default environment variable in the bash shell which contains your username.
Sudo requires you to enter your user password. It’s the same password you use when you log in to Mac OS X. To install rar you can use the same command:
sudo install -c -o $USER rar /bin
Do a test-run to see if the installation went properly. In your terminal now enter from any location you want:
unrar