How to use unrar and rar commands on Ubuntu Linux

Ubuntu Linux background with penguin

This article explains managing RAR files with unrar and rar commands on Ubuntu Linux.

The unrar command can easily manage RAR files on Ubuntu Linux. This command allows you to list, extract, and test files from RAR archives for integrity.

You’ll first need to install the unrar package on your system to get started. Once you have unrar installed, you can use the command to extract files from your RAR archives. You can also use the command to test your archives’ integrity to ensure they are not corrupted.

Unlike the unrar command, the rar command will let you archive a RAR file format. You must also install the rar package to use the rar command.

About unrar command:

The unrar command lets you easily extract RAR files on Ubuntu Linux. The command allows you to list, password-protect, and extract files from RAR archives.

The rar command lets you create RAR files on Ubuntu Linux.

Syntax:

The syntax is the rule and format of how the unrar and rar commands can be used. These syntax options can be reordered, but a straight format must be followed.

The unrar package isn’t installed on Ubuntu Linux by default. To use it, you must first install the unrar package.

Run the command below to install it.

sudo apt install unrar

Below is an example syntax of how to use the unrar command.

nrar [options]

Options:

The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the commands. They are separated by spaces and followed after the commands.

Below are some options for the unrar command:

 Options:Replace Options: with the options to run with the uptime command
 -eUse the -e option to extract files without archived paths
 -l, [t[a],b]  Use the -l option to list archive contents [technical[all], bare]
 -tUse the -t option to test archive files
-xUse the -x option to extract files with full path
-pUse the –p option to create an archive and set a password
 -V, –versionoutput version information and exit

Now that you have installed the unrar package follow the steps below to learn how to use it to extract and manage RAR files.

Extract RAR files

Run the unrar command with the -e option to extract a RAR archive. By default, it will output the content in the same directory.

unrar e filename.rar

To extract a RAR file into a specific directory, use the unrar command with the -x option.

unrar x filename.rar /path/to/extracts

List RAR file content

To list the content of a RAR file, run the unrar command with the -l option.

unrar l filename.rar

Create RAR file on Ubuntu Linux.

You can use the command line utility called “rar” to create a RAR file in Ubuntu Linux. First, make sure you have the “rar” package installed by running the command below.

sudo apt-get install rar

Create RAR archive

Once the rar package is installed, run the command below to create a RAR archive.

rar a filename.rar file1 file2 file3 file4 file100

You can use the rar command with the -u option to add files to a RAR archive.

rar u filename.rar file7 file8 file9

Password protect RAR archive

Users can use the -a and -p options to password-protect a RAR archive.

rar a -p filename.rar file1 file2 file3 file4 file100

When you do that, the command will prompt you to create a password.

Check out their man pages for more about the unrar and rar commands.

unrar man page:

Usage:     unrar <command> -<switch 1> -<switch N> <archive> <files...>
               <@listfiles...> <path_to_extract/>

<Commands>
  e             Extract files without archived paths
  l[t[a],b]     List archive contents [technical[all], bare]
  p             Print file to stdout
  t             Test archive files
  v[t[a],b]     Verbosely list archive contents [technical[all],bare]
  x             Extract files with full path

<Switches>
  -             Stop switches scanning
  @[+]          Disable [enable] file lists
  ad[1,2]       Alternate destination path
  ag[format]    Generate archive name using the current date
  ai            Ignore file attributes
  ap<path>      Set path inside archive

rar man page

NAME
       rar - archive files with compression

SYNOPSIS
       rar <command> [-<switch 1> -<switch N>] archive [files...] [@listfiles...] [path_to_extract]

COMMANDS
       After the program name comes a command and then optional switches with dashes before them.
       A summary of commands is included below.  For a complete description, run rar -?

       a      Add files to archive.

       c      Add archive comment. Comment length is limited to 256 KB.

       ch     Change archive parameters.  Can be used with most of archive modification options.

       cw     Write archive comment to a specified file.

       d      Delete files from archive.

       e      Extract files to current directory. Does not create any subdirectories.

That should do it!

Conclusion:

This post showed you how to use the unrar and rar commands to manage RAR files in Ubuntu Linux. If you find any errors above or have something to add, please use the comments form below.

Posted by
Richard

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: