Using php5-rar to extract files with an RAR extension
There does not appear to be any freeware RAR compression software according to this Wikipedia article. However, if you are willing to consider trialware (or "nagware"), you can download the commandline RAR for OS X (also see here).