normal tar file:
Modern Tar can use xf option to extract any file.
tar xf archive.tar.xz
tar xf archive.tar.gz
tar xf archive.ta

Extract the file to another folder:

tar -xf file.name.tar -C /path/to/directory
Install unrar

Under Debian or Ubuntu Linux, you need to type apt-get command as follows to install unrar program:
# apt-get install unrar

If you are using Fedora core Linux / CentOS / RHEL, use yum command as follows (see discussion below for more):
# yum install unrar

If you are using FreeBSD, enter:
# pkg_add -v -r unrar

If any of above, methods is not working for you, download binary package from official rarlab site:
$ cd /tmp
$ wget http://www.rarlab.com/rar/rarlinux-3.6.0.tar.gz

Next, untar file, enter:
$ tar -zxvf rarlinux-3.6.0.tar.gz

Both unrar and rar commands are located in rar sub-directory. Just cd to rar directory, type:
$ cd rar
$ ./unrar

Now copy rar and unrar file to /bin directory, type:
# cp rar unrar /bin

HowTo: Use unrar Command

The unrar command supports various options, below are common options that you need to for extracting files.

Task: Exreact rar (unpack) File

To extract file.rar file into the current directory, enter:
$ unrar e file.rar

Task: List (l) file inside rar archive:

$ unrar l file.rar

Task: To extract (x) files with full path type command:

$ unrar x file.rar

To test (t) integrity of archive, file type command:
$ unrar t file.rar