Managing RAR Files on Ubuntu: Unrar & Rar Commands Guide
Managing RAR files on Ubuntu involves using two command-line tools: `unrar` and `rar`.
The `unrar` command helps you open and check RAR archives, which are a popular way to compress files. Think of it as the tool you use to get files *out* of a RAR archive.
The `rar` command, on the other hand, lets you create your own RAR archives. You’ll use this when you want to pack files *into* the RAR format on your Ubuntu system.
Before you can use these tools, you need to install them. For instance, you can install `unrar` by typing `sudo apt install unrar` into your terminal.
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 on Ubuntu is a handy tool for managing RAR files. It helps you open RAR archives, see their contents without unpacking, and even create password-protected RAR files. The related rar command is used specifically for making these archives on Ubuntu.
The rar command lets you create RAR files on Ubuntu Linux.
Syntax:
The syntax defines the rules and format for using the `unrar` and `rar` commands. You can reorder these syntax options, but you must follow a clear format for the `unrar` and `rar` commands.
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
You can easily extract RAR files on Ubuntu using the unrar command. To unpack all files into your current folder, just type ‘unrar e filename.rar’. If you want to put the extracted files in a different location, use ‘unrar x filename.rar /path/to/extracts’ to pick a specific destination folder.
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
Protecting your RAR archives with a password on Ubuntu is straightforward using the rar command. Simply type ‘rar a -p archive_name.rar file1 file2 file3’, and the command will prompt you to set a password. This ensures your RAR files are secured right when you create them.
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.
Can RAR files be opened on Linux?
To handle RAR files on Linux, you need to install the rar and unrar utilities. Unfortunately, these aren't included by default in many Linux distributions because RAR is proprietary software. Once installed, you're ready to start working with RAR files.
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!