rar is a command tool for archiving and extracting RAR files. Its official website is here.
Archive
Archive $FILE to $FILE.rar:
rar a $FILE $FILE
Archive all files in current directory to $FILE.rar:
rar a $FILE *
Archive $FILE without compression:
rar a -m0 $FILE $FILE
Archive $FILE with 10% recover record:
rar a -rr10p $FILE $FILE
Archive $FOLDER and all its subdirectories to $FILE.rar:
rar a -r $FILE $FOLDER
Archive $FILE with password $PASSWORD:
rar a -p$PASSWORD $FILE $FILE
If you want the metadata encrypted too, use -hp instead of -p.
Archive $FILE with split of 1 GiB:
rar a -v1g $FILE $FILE
Archive $FOLDER and all its subdirectories with split of 2 GB, 10% recover record and password $PASSWORD, which encrypts all contents:
rar a -r -rr10p -v2G -hp$PASSWORD $FOLDER $FOLDER
Note: G and g are different. G means 10003 bytes while g means 10243 bytes. The same is with M and m, K and k. Default unit is K.
Extract
Extract $FILE.rar to current directory:
rar x $FILE
Extract $FILE.rar with password $PASSWORD to directory $DIR:
rar x -p$PASSWORD $FILE $DIR
You can see full usage from here.