[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedOctober 6, 2023

How to Extract and Create RAR Files.

How To Extract And Create RAR Files.

Usually, you’ll come across the .zip or .gz compressed files. However, every now and then, you’ll also encounter RAR files in Linux.

Dealing with RAR files in the Linux command line is not that complicated.

You extract RAR files with the unrar command:

unrar x file.rar

Similarly, you can create RAR file archive from a given files and folders using the rar command:

rar a output_file.rar files_or_folders_to_archive

 

Install RAR archive support in Linux

There are two components involved here. You need:

  • unrar command: To extract a RAR file

  • rar command: To create a RAR file

You can install either or both, depending on your needs.

In Ubuntu and Debian-based distros, use:

sudo apt install rar unrar

In Arch and Manjaro, use the pacman command:

sudo pacman -S rar unrar

In Fedora-based Linux distros, use:

sudo dnf install rar unrar

In Red Hat, use the yum commands:

sudo yum install rar unrar

In SUSE, use the zipper command:

sudo zypper install rar unrar

 

List the contents of the RAR file (without extracting it)

If you just want to peek into the contents of the RAR file, use the listing option l like this:

unrar -l file.rar

 

Extracting RAR Files in Linux

You can easily extract the contents of the RAR file in the present working directory from where you are running the command.

unrar e file.rar

You can instruct the unrar command to extract the file to another directory location like this:

unrar e file.rar extract_to_another_dir

 

Extract the RAR file and retain the directory structure

I believe the extracted file should retain the directory structure inside the RAR file.

Thankfully, the unrar command does allow to do that with the use of option -x:

unrar x file.rar

Let’s take the same sample file tag.rar and extract it with option -x so that it keeps the same directory structure.

So, when I extracted tag.rar file this time, it is extracted to a directory called tags-images and contains the following:

root@liviu$ tree tags-images/
tags-images/
├── courses.png
├── guides.png
├── privacy.png
├── trivia.png
└── vr
    ├── boy-with-vr-glasses-play-with-virtual-videogame.jpg
    └── images.jpeg

2 directories, 6 files

Now, where did this tags-images come from? Actually, that’s the original folder name from which the tag.rar file was created. You can see it when you list the contents of the RAR file.

Similar to the previous option, you can also extract the file to another directory location:

unrar x file.rar extract_to_another_dir

 

Creating RAR archive file in Linux

Creating a RAR archive file in Linux is rather simple. You use the rar command for this purpose in the following way:

rar a archive.rar files_and_folders_to_archive

The output file name is mandatory but you may skip the .rar extension as it is automatically added if not specified.

Keep reading
How to use tac command in Linux.
September 13, 2023

How to use tac command in Linux.

What is tac command: tac command in Linux is used to concatenate and print files in reverse. This command will write each FILE to standard output, the last line first. When no file is specified then this command will read the standard input. Syntax: tac [OPTION]… [FILE]… Options: tac -b: This…

Read article
How to use and install neofetch.
September 13, 2023

How to use and install neofetch.

How To Use And Install Neofetch. Neofetch displays an ASCII logo of your Linux distribution along with information related to your system in the terminal. Many Linux users will use it in screenshots of their desktops just because they think it’s cool. And they’re right. You can use it to show off…

Read article
How to use whatis command in Linux.
September 13, 2023

How to use whatis command in Linux.

How To Use Whatis Command. The whatis command is used to get brief information about Linux commands or functions. It displays the manual page description in a single line of the command that passes with the whatis command. It searches for the strings that have been passed with it from its index…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00