How To Create RAR Archive In Linux?

How To Create RAR Archive In Linux?


This post was last updated on August 1st, 2020 at 12:59 pm

Like other archives, a RAR file is a data container that stores one or several files in compressed form. RAR is a proprietary file format which is developed by Eugene Roshal. It is a native file format for the WinRAR archiver.

RAR file uses .rar file extension. It is frequently used in Windows OS. If you have downloaded such a file then first you need to extract the RAR file with an application that supports RAR file format and then you can use it. WinRAR application is officially not available for Linux but we can use some other applications to create or extract a RAR file.

But, ahead in this article, we will discuss how to create a RAR file in Linux. Opening and extracting of RAR file will be covered in separately.

How to Install rar command in Lunux?

We will use the rar command for archiving files with compression in the RAR file format. So first we need to install it in our system, Use the following command to install it-

Debian Based Ubuntu, Linux Mint etc:

If you are using a Debian based distribution such as Ubuntu, Linux Mint, etc. then use –

sudo apt install rar


sudo apt-get install rar

RPM-based Cent OS, RedHat Linux etc:

Or if you are using an rpm-based Linux distribution such as centos, Redhat, etc then use –

sudo yum install rar

For Fedora:

To install rar in Fedora, use –

sudo dnf install rar

Once the installation gets completed you can use the rar command to create rar files.

How to Create a RAR file in Linux?

To create a rar file we will have to use rar command with the option a in the terminal. Suppose I have a directory named sample which contains some files in it. Now to create sample.rar we will use the following command in our terminal –

rar a sample.rar sample

Once you execute this command you will see output something like given in the below image –

This will create a file named sample.rar inside the same directory.

Update a RAR file

To update or add a file to an existing rar file you need to use u option with rar command. Now execute the following command in your terminal. here we are going to add abc file to sample.tar –

rar u sample.tar abc

Display the list of files and directories inside a rar file

To display the list of files and directories within a rar file use the option l with the rar command –

rar l sample.rar

Deleting a RAR file

Now if you want to delete a rar file then you can use the following command in your terminal this will delete every file of inside it –

rar d filename.rar


The rar program provides a lot more options that you can use with the rar command. You can check them in the manual page of the rar. Execute the following command to see manual page-

man rar
Previous How To Open and Extract RAR Files In Linux?
Next Understanding the Filesystem (Directory Layout) In Linux

About author

You might also like

Linux Topics 0 Comments

How To Mount And Unmount File Systems From The Linux Terminal?

This post was last updated on August 1st, 2020 at 12:13 pmIn Linux or Unix, mount command is used to mount(attach) a filesystem or storage device to a specific directory

Linux Topics 0 Comments

How To Find A File Or Directory Quickly In Linux/Unix?

This post was last updated on August 2nd, 2020 at 12:47 pmSearching a file manually in Linux or Unix can be a little bit challenging task especially for new users.

How To 0 Comments

How To Setup NFS In Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 12:22 pmNFS or Network file system is a distributed filesystem protocol. It allows a remote host to mount filesystem over


No Comments Yet!

You can be first to comment this post!

Leave a Reply