Как разархивировать файл rar в linux
Перейти к содержимому

Как разархивировать файл rar в linux

  • автор:

How to Use RAR files in Ubuntu Linux [Quick Tip]

RAR is a quite good archive file format. But, it isn’t the best when you’ve got 7-zip in Linux offering great compression ratios and Zip files being easily supported across multiple platforms by default.

It is one of the most popular archive formats, but, Ubuntu‘s archive manager does not support extracting RAR files nor does it let you create RAR files. It would rather show you this error:

There is no command installed for RAR archive files. Do you want to search for a command to open this file?

Ubuntu RAR File Error

Fret not, we have a solution for you. To enable the support to extract RAR files, you need to install UNRAR – which is a freeware by RARLAB. And, to create and manage RAR files, you need to install RAR.

Extracting RAR Files in Linux

Unless you have it installed, extracting RAR files will show you an error “Extraction not performed“. Here’s how it should look like (Ubuntu 18.04):

Error in RAR extraction in Ubuntu

If you want to resolve the error and easily be able to extract RAR files, follow the instructions below to install unrar.

Step 1: Install unrar package from multiverse repository

Launch the terminal and type in the following command to make sure you have multiverse repository enabled in Ubuntu:

Update the package cache:

Now install unrar package:

Step 2: Extract RAR files either graphically or via command line

After installing unrar, you may choose to type in “unrar” (without the inverted commas) to know more about its usage and how to use RAR files with the help of it.

The most common usage would obviously be extracting the RAR file you have. So, you can either perform a right-click on the file and proceed to extract it from there or you can do it via the terminal with the help of this command:

You can see that in action here:

Using unrar in Ubuntu

If the file isn’t present in the Home directory, then you have to navigate to the target folder by using the cd command in Linux. For instance, if you have the archive in the Music directory, simply type in “cd Music” to navigate to the location and then extract the RAR file.

Creating & Managing RAR files in Linux

UNRAR does not let you create RAR files. So, you need to install the RAR command-line tool to be able to create RAR archives.

To do that, you need to type in the following command:

Here, we will help you create a RAR file. In order to do that, follow the command syntax below:

When you type a command in this format, it will add every item inside the directory to the archive. In either case, if you want specific files, just mention the exact name/path.

By default, the RAR files reside in HOME directory.

Using rar archive in Ubuntu Linux

In the same way, you can update/manage the RAR files. Just type in a command using the following syntax:

To get the list of commands for the RAR tool, just type “rar” in the terminal.

How to Extract RAR Files in Ubuntu Linux

For users who don’t know, a RAR file is a compressed file that is split into a set of multi-volume files. This is usually done in cases where there are large file sets that are needed to be shared or transferred, hence are compressed into a zip file. Similarly, for zip files, when they are transferred or downloaded from the internet need to be extracted. A number of tools are available to help extract and compress these files within seconds, regardless of their size or quantity.

Extracting RAR Files in Linux distributions

RAR is a free tool that is pre-installed on Windows operating systems but unfortunately doesn’t support Linux platforms. If you will try extracting in Ubuntu, the archive manager will show you the following dialogue box:

This is because the system won’t recognize the file type like Windows and does not have any supported tool to extract it. In other cases, it will also display an error somewhat like this:

Read on below to find out how you can install RAR tools on Linux and use those to open, extract, and compress a file.

How to Install Unrar tool in Linux

Unrar is compatible mostly for Linux distributions where you can easily install the package from the command terminal using the apt programs.

Open Command Terminal and type the following command(s) if you’re using Ubuntu or Debian based distros:

If you are using Fedora distro, type the command in your command prompt:

For users using CentOS/ RHEL 64-bit distros, you can install the Unrar tool using these commands:

(Just remove ‘x64’ from the above command if you want to alter it for 32-bit systems)

How to Extract a RAR File in Linux

To open or extract a .rar extension file in your current working directory, type the following command in the terminal:

This will start extracting your file using the Unrar tool like this below:

Note: Since you have the Unrar tool, you can also perform these operations directly through the right click, besides using these commands on the terminal.

To open or extract a .rar extension file in any specific path or directory, type the following command in the terminal. This will extract the files and locate them in the specified directory.

If you want to open or extract a .rar extension file in their original directory, use the following command:

How to View Contents inside a RAR File in Linux

A compressed file contains multiple files of large sizes that are zipped together inside it. If you want to list out all the file contents inside an archive file, use the command below. This will display a list of files with their name, size, time, date created and permissions.

Testing a RAR File in Linux

If for instance, you have downloaded a file from the internet and would like to test its integrity, the Unrar tools offers that too. The following command will do a complete check on the archive file and its contents, and then show the results. Type:

The unrar tool that we just downloaded uses the unrar command to carry out the above tasks. It lets you extract, list out and test files. There is no option for creating a rar file with this particular tool. Therefore, we will install another Linux command-line utility called RAR to create compressed/archive files.

Installing RAR in Linux

To install the RAR command option, type the following commands in the terminal:

After you execute the commands, the result will be:

Creating RAR Files in Linux

In order to create a .rar file in Linux distribution, you will need to run the following command:

This will create an archive file name ‘filename’ for the directory filename1. See how this will look like below:

Deleting Files from any Archive

Out of the multiple files in an archive, if you want to delete a particular file through the command terminal, type the following command:

Recovering deleted Archives

If you deleted an archive file by accident or lost it through data loss, don’t worry, you can always recover it back. The following command will recover the file back or will fix it if there has been any loss or damage.

Setting password on a Particular Archive

This incredible Rar tool lets you do a number of interesting things with your archive files from creating, deleting, and adding, to changing their directories and protecting them through passwords.

If you want to protect your files from unknown access or extraction, you can set a password on them. To password-protect your file, type the following command:

Now, to verify the changes, type the command to open the directory to see if it asks for password.

Wrap Up

RAR and UNRAR are very useful when it comes to handling and managing files in Linux. They provide multiple options to make your work easier and more convenient. When compared to Windows, things get a little complicated for Ubuntu, but these commands are simple, easy to execute and give results within seconds.

If you need more description on the commands, just the run the following two:

Как распаковать rar в Linux

В операционной системе Windows часто используются два формата архивов, это ZIP и RAR. Они наиболее часто применяются для сжатия файлов и хранения их на компьютере. Но в Linux немного другая система, здесь для сжатия всех данных используется формат tar.gz. По умолчанию в системе не поставляются инструменты для работы с архивами форматов Linux.

В одной из предыдущих статей мы рассматривали как распаковать zip в Linux. В сегодняшней статье мы сосредоточимся на втором формате и рассмотрим как распаковать rar linux. Рассмотрим несколько способов и утилит, с помощью которых вы сможете решить эту задачу.

Как распаковать RAR в Linux

Формат RAR был разработан российским программистом, Евгением Рошалом, отсюда и название формата — Roshal ARchiver. Изначально формат был разработан для DOS и поддерживал несколько улучшений по сравнению с уже использовавшимся тогда ZIP. Сразу была поддержка большого количества файлов, разбиения архива на части и создания самораспаковывающихся архивов.

Распаковка rar linux выполняется с помощью утилиты unrar. А упаковка архива командой rar. Обычно она не поставляется в системе по умолчанию, но вы можете очень просто установить ее из официальных репозиториев. Для установки утилиты в Ubuntu выполните такую команду:

sudo apt install unrar

В Fedora и других системах, использующих пакеты rpm, имя будет точно таким же, только будет отличаться пакетный менеджер:

sudo yum install unrar
sudo dnf install unrar

Перед тем как перейти к работе с командой и рассмотрению того как распаковать rar linux давайте рассмотрим ее синтаксис:

$ unrar команда опции архив файлы путь_для_расспаковки

Основной смысл работы утилиты уже понятен, но рассмотрим ее параметры подробнее:

  • e — распаковать архив;
  • l — вывести список файлов внутри архива;
  • p — вывести распакованный файл в стандартный вывод;
  • t — проверить архив;
  • v — вывести подробную информацию про архив;
  • x — извлечь файлы, сохраняя полный путь внутри архива.

Опции настраивают поведение утилиты, рассмотрим основные опции, которые могут вам понадобиться:

  • -ad — добавить имя архива к пути распаковки;
  • -ai — игнорировать атрибуты файлов;
  • -inul — не выводить сообщения об ошибках;
  • -p — указать пароль архива;
  • -sl — распаковывать только файлы, меньше указанного размера;
  • -u — обновить уже распакованные файлы;
  • -y — отвечать y на все вопросы;
  • -x — не распаковывать указанные файлы;
  • -ts — сохранять временную метку исходных файлов.

Основные опции, которые вам могут понадобиться мы рассмотрели, теперь давайте приведем несколько примеров как работать с утилитой. Чтобы извлечь файлы из архива в текущую папку достаточно передать утилите имя архива и команду e:

unrar e file.rar

rar4

Вы можете вывести содержимое архива, ничего не распаковывая с помощью команды l:

unrar l file.rar

rar1

Чтобы сохранять полный путь, который прописан в архиве нужно использовать команду x:

unrar x file.rar

rar

Также вы можете проверить архив на целостность с помощью команды t:

unrar t file.rar

rar2

Кроме того, вы можете указать папку, в которую стоит распаковывать файлы:

unrar e file.rar

rar3

Это все команды unrar, которые вам могут понадобиться при повседневной работе с архивами, обратите внимание, что после установки утилиты unrar многие менеджеры архивов, например, Arc, теперь тоже поддерживают этот формат:

rar5

Но без этой утилиты вы получите ошибку что утилита не знает что это за формат архива. Всем графическим программам нужен этот rar архиватор linux.

Выводы

В этой небольшой статье мы рассмотрели как выполняется распаковка rar linux с помощью утилиты unrar или других графических утилит. Как видите, все делается очень просто, если у вас остались вопросы о том, как разархивировать rar linux, спрашивайте в комментариях!

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

What's the easiest way to unrar a file?

I just realized I can’t unrar .rar files on my Ubuntu machine!

What’s the easiest way to accomplish this fundamental task? If possible I’d love something like 7Zip that I can just right Click, and extract and have the program worry about how to do it regardless if it’s a .zip, a .rar or a .foo compressed file.

7 Answers 7

Ubuntu by default uses File Roller, which supports the following formats:

Keep in mind, that this is just graphical front-end, so you still need to install unrar for .rar support;

The unrar package is hosted on the Multiverse repository, so first you’ll need to enable the Multiverse repository in Software & Updates;

Then you can install the package either by using Software Centre or by opening Terminal and running sudo apt-get install unrar .

wjandrea's user avatar

You could read man unrar .

From terminal you can use next command:

Or, the following command if you want to preserve the directory structure too:

Install unrar from the Software Center or by running the command

Zanna's user avatar

Lincity's user avatar

If you like then you can also use p7zip-full package. You can install it as:

The main purpose of this package is to provide 7z and 7za file archivers with high compression ratio.

Raja G's user avatar

I tried the above command on Ubuntu 16.04, but it didn’t work.

The following command worked fine for me:

BeastOfCaerbannog - On strike's user avatar

Ramesh Chand's user avatar

The half-GUI method:

Then, in your favorite file manager (ex: nemo, my favorite, or nautilus [Ubuntu’s default]), right-click the .rar file and go to Extract Here . Done!

enter image description here

Here are some free alternatives to the non-free unrar package:

The libarchive-tools package provides the bsdtar command that can extract many file formats, including RAR files. To install:

Extract RAR files using:

The unar package provides the unar command for extracting a variety of file formats, including RAR files. To install:

Extract RAR files using:

Another free alternative is the unrar-free package. However, unrar-free is only able to extract RAR files, unlike bsdtar and unar which are able to extract many file formats. Furthermore, starting in Ubuntu 22.04 (Jammy Jellyfish), unrar-free is just a wrapper around libarchive (just like bsdtar ), which makes unrar-free redundant.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *