Managing RAR Files on Ubuntu: Unrar & Rar Commands Guide
Managing RAR files on Ubuntu requires two core terminal tools: unrar for opening compressed archives and rar for creating them. Because Ubuntu omits these packages by default, you need to add them before working with .rar folders.
You can set up the extraction utility instantly by opening your terminal and running sudo apt install unrar.
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 built-in terminal utility used for managing RAR files on Ubuntu. It lets you open archives, view file contents without full extraction, and handle compressed data efficiently. The companion rar command is used alongside it specifically to create new archives.
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
Extracting RAR files on Ubuntu is done using the unrar command in your terminal. You can unpack all files into your current folder with a single command, or point the tool to a specific destination folder if you want the contents placed elsewhere.
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
Password protecting a RAR archive on Ubuntu requires the rar command with a specific flag during creation. Running the command prompts you to type a secure password, ensuring your files stay locked and private right from the start.
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!