Managing RAR Files on Ubuntu: Unrar & Rar Commands Guide
You can manage RAR files on Ubuntu Linux using the command-line utilities `unrar` and `rar`.
The `unrar` command extracts and tests RAR archives, while the `rar` command creates them. You’ll typically use `unrar` to unpack downloaded files, and `rar` if you need to package files into the RAR format on Ubuntu.
To begin, you need to install the `unrar` and `rar` packages. For example, you can install `unrar` with the command `sudo apt install unrar`.
Once installed, `unrar` lets you easily extract contents from your RAR files. You can also use it to check if an archive is corrupted.
Install the `unrar` package using `sudo apt install unrar`. Extract files with `unrar e filename.rar` or list contents using `unrar l filename.rar`. Create archives with the `rar` command after installing its package.
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 of syntax for using 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 |
| -e | Use the -e option to extract files without archived paths |
| -l, [t[a],b] | Use the -l option to list archive contents [technical[all], bare] |
| -t | Use the -t option to test archive files |
| -x | Use the -x option to extract files with full path |
| -p | Use the –p option to create an archive and set a password |
| -V, –version | output 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:
- In this article, we have covered the usage of the unrar and rar commands to manage RAR files in Ubuntu Linux.
- The unrar command allows for effortless extraction, listing, and testing of RAR archives, while the rar command enables the creation of RAR files.
- By following the provided syntax and options, users can effectively extract, list, and test RAR files using the unrar command and create RAR archives using the rar command.
- For added security, the -p option with the rar command can be used to password-protect RAR archives.
- Implementing these commands empowers users to handle RAR files within the Ubuntu Linux environment efficiently, enhancing their file management capabilities.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!