Rar Unrar Command Line

November 5, 2011 by: Youzhny

Here we will teach you how to use the rar and unrar programs in Linux command line. These programs are virtually a must have for most people that have any computer experience. We will show you how to use to rar and unrar, how to install them, and some advanced options that you may need. These next commands will help you get the programs installed.

$ sudo apt-get install rar

$ sudo apt-get install unrar

$ rar command -switch archive.rar files.jpg – This is the common usage for the rar program. Use this command to archive files in the normal fashion. We will explain how to use unrar at the bottom of this section.
Rar Commands

When using the rar program there are several commands that can be chosen from for different functions. Just insert the command you need to specify the rar operation you desire. Here are a few basic rar commands.

a – Add files to archive.

$ rar a archive.rar files.jpg – Just insert your additional commands after the rar command and before your desired switches. Here are a few more commands.

c – Add a comment to your archive.

d – Delete files from your archive.

e – Extract files to your current directory.

x – Extract files with full path.

f – Freshen the files in your archive with this command. This will update files changed since they were added the the archive. It will not add new files to your archive.

r – Repair a damaged archive.

rc – Reconstruct missing volumes, usable for multi-volume rar archives.

rr[N] – Add a data recovery record to your archive.

rv[N] – Create recovery volumes that can later be used to rebuild damaged or missing files. This will create a .rev file usable for missing multi-volume archives.

t – Test your archive.

u – Update your archive. This will add new files and update changes made since the archive was created.

l[t] – List the content of your archive.

v[t] – Verbosely list archive contents. Same as above.
Rar Switches

Rar switches can be used alongside commands, however every switch must be seperated by a space. Here are a few of the typical switches used with the rar program.

-as- Synchronize archive contents. When this switch is used the files not present in the update list will be deleted from the archive so use with caution.

-cl – Convert file names to lower case.

-cu – Convert file names to upper case.

-df – Delete files after archiving.

-ds – Do not sort files while adding to a solid archive.

-ed – Do not add empty directories.

-f – Freshen files. This may be used for extracting or creating new archives.

-hp– File data and headers will be encrypted. The password IS case sensitive and entering a password is mandatory.

-m0 to -m5 – Set the compression level of your archive. By default -m3 is used by rar. Change these settings to sacrifice speed or compression at the benefit of the other as you wish.

-o+ – Overwrite existing files.

-o- – Do not overwrite existing files.

-p– Encrypt files only with the case sensitive password you choose.

-p- – Do not ask for password.

-r – Recursive subdirectories.

-rr[N] – Add data recovery record.

-rv[N] – Create recovery volume.

-t – Test files after archiving.

-u – Update files.

-v– Creates multiple volumes of the size you specify. Useful for multi-volume archives only.
Unrar Commands

$ unrar command -switch archive.rar files.jpg /path/to/files

This is the common usage for the unrar command, additional commands and switches follow as shown above. Here are a few basic commands you can use with the unrar program.

e – Extract files to the current working directory.

l – List the contents of an archive.

t – Test the integrity of archived files.

v – Verbosely list the contents of an archive.

x – Extract files with full paths.
Unrar Switches

All switches must be seperated by a space and have dashes before them.

-c- – Disable showing comments.

-f – Freshen files.

-o+ – Overwrite existing files.

-o- – Do not overwrite existing files.

-p– Use a password to extract the archive.

-p- – Do not ask for password.

-r – Creates recursive subdirectories while extracting.

-u – Update all files.

-v – List all volumes.

-x– Exclude the file you specify.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Have you found this script useful? Please support author by PayPal donation.


One Response to “Rar Unrar Command Line”
  1. rwesdf says:

    for 32bit:
    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm

    For 64 bit


    Install DAG’s GPG key
    rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

    Install the package
    For 32 bit
    rpm -i rpmforge-release-0.5.1-1.el5.rf.i386.rpm

    For 64 bit
    rpm -i rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

    Install Rar and Unrar
    yum install rar unrar

    Reboot server

Leave a Reply