How To List and Unrar Rar Files In Ubuntu, Debian, Kali, Mint? – POFTUT

How To List and Unrar Rar Files In Ubuntu, Debian, Kali, Mint?


Rar is a very popular compression format used for different purposes. A lot of files like documents, image files, source code, etc. are compressed using rar compression format. In this tutorial, we will look at how to install rar tool for Ubuntu, Debian, Kali, and Mint and then list and extract files and directories.

Install Unrar

We will use apt package manager in order to install unrar package.

$ apt install unrar
Install Unrar
Install Unrar

List Rar File Contents

We can list contents of a rar files with l option and the rar file name. In this example we will list contents of rar file named ans.rar .

$ unrar l ans.rar
List Rar File Contents
List Rar File Contents

The list operation will print attributes, size, date time and names.

Unrar All Files and Directories

We can use e option in order to extract all files and directories inside a rar file. In this example, we will extract contents of ans.rar . -r is used to extract recursively which means all sub files and directories will be extracted too.

$ unrar e -r ans.rar
Unrar All Files and Directories
Unrar All Files and Directories

Unrar Single File or Directory

Some times we may need to extract only a single file or directory from a rar file. This may be a backup rar file where we only need a single file or directory. We need to specify the file and directory path and name in a relative manner. In this example, we will extract a file named data.txt

$ unrar e ans.rar data.txt

Or if the file is locate in the back/files directory we can use following command.

$ unrar e ans.rar back/files/data.txt

Preserve Directory Structure

While taking backups with rar command the absolute directory path can be stored into the rar file. This is useful for the recovery process where we do not need to specify the extract path explicitly. We can use x option in order to preserve the directory structure while extracting. We will use -r as a recursive extract.

$ unrar x -r ans.rar

LEARN MORE  Linux tar Command and How To Tar A Directory

Leave a Comment