unrar - Linux


unrar is a command-line utility used to extract or view files from RAR archives. Primarily used for decompressing files compressed in the RAR format, it’s especially useful in environments where GUI-based tools are not available or practical.


The basic syntax of the unrar command is:

unrar <command> [options] <rar_file> [path_to_extract]
  • <command>: Defines the operation like x for extract files with full path, e for extract files without directory.
  • [options]: Modifiers that change how the unrar behaves.
  • <rar_file>: The archive to operate on.
  • [path_to_extract]: Optional path where files will be extracted; if omitted, extraction is to the current directory.


  • -x <file>: Exclude specified file from being extracted.
  • -p<password>: Use provided password to decrypt protected archives.
  • -o+: Overwrite existing files without prompting.
  • -o-: Do not overwrite existing files.
  • -f: Freshen existing files, i.e., only replace older files in the destination.
  • -u: Update files, replacing older files, and adding new files.
  • -t: Test files after extracting to ensure integrity.

For example, to extract all files from archive.rar without prompting for overwrite, use:

unrar x -o+ archive.rar


  1. Extracting an Archive

    unrar x archive.rar

    This extracts all files from archive.rar into the current directory, maintaining the directory structure.

  2. Extracting to Specific Directory

    unrar x archive.rar /path/to/destination/

    Extracts all files into /path/to/destination/.

  3. Extracting with Password

    unrar x -pYourPassword archive.rar

    Extracts the contents using YourPassword as the decryption key.

Common Issues

  • Missing File Errors: Occurs if the specified RAR file does not exist. Double-check file names and paths.
  • Corrupted Archive Errors: Use the -t option to test the integrity of the archive.


unrar can be combined with other commands for advanced operations. Here’s a script snippet that finds all RAR files in a directory and extracts them to individually named folders:

for file in *.rar; do
  mkdir -p "$dir"
  unrar x "$file" "$dir/"
  • rar: Used to create RAR archives. Can be used in tandem with unrar for managing RAR files.
  • zip/unzip: Tools for handling ZIP files, a different format also widely used for file compression.

Further documentation and updates can be found on the RARLAB website.