How to unpack rar linux

Содержание
  1. How to Open, Extract and Create RAR Files in Linux
  2. Step 1: How to Install Unrar in Linux
  3. Step 2: How to Open/Extract a RAR File in Linux
  4. Step 3: How to List a RAR File in Linux
  5. Step 4: How to Test a RAR File in Linux
  6. Step 5: How to Install Rar in Linux
  7. Step 6: How to Create Rar File in Linux
  8. Step 7: How to Delete files from Archive
  9. Step 8: How to Recover Archives
  10. Step 9: How to Update Archives
  11. Step 10: How to Set Password to Archives
  12. Step 11: How to Lock Archives
  13. Conclusion
  14. If You Appreciate What We Do Here On TecMint, You Should Consider:
  15. Распаковка и создание RAR архивов в Linux. Команды unrar, rar
  16. Установка UNRAR
  17. Распаковка RAR-архивов
  18. Список файлов в архиве
  19. Протестировать архив
  20. Распаковать RAR с паролем
  21. Другие возможности команды UNRAR
  22. Создание RAR архивов в Linux
  23. Установка пакета RAR
  24. Создать RAR архив
  25. Указать степень сжатия
  26. Разбить архив на несколько файлов
  27. Добавить файлы в архив
  28. Удалить файлы из архива
  29. Восстановить битый архив
  30. Создать архив с паролем
  31. Распаковать архив
  32. Другие возможности команды RAR
  33. Как извлечь файлы RAR в Linux
  34. Установка Unrar
  35. Ubuntu
  36. Debian
  37. Arch Linux
  38. Fedora
  39. OpenSUSE
  40. Извлечь файлы RAR – Терминал
  41. How to Use RAR files in Ubuntu Linux [Quick Tip]
  42. Extracting RAR Files in Linux
  43. Step 1: Install unrar package from multiverse repository
  44. Step 2: Extract RAR files either graphically or via command line
  45. Creating & Managing RAR files in Linux
  46. About Ankush Das

How to Open, Extract and Create RAR Files in Linux

RAR is a most popular tool for creating and extracting compressed archive (.rar) files. When we download an archive file from the web, we required a rar tool to extract them.

RAR is available freely under Windows operating systems to handle compressed files, but unfortunately, rar tool doesn’t pre-installed under Linux systems.

This article explains how to install unrar and rar command-line tools using official binary tar file under Linux systems to open, extract, uncompress or unrar an archive file.

Step 1: How to Install Unrar in Linux

On Debian and Ubuntu based distributions, you can easily install unrar package using the apt-get or apt program as shown.

If you are using Fedora distribution, you can use the dnf command to install it.

If you are using a CentOS / RHEL distribution, you need to download the latest unrar/rar file and install it using following commands.

Step 2: How to Open/Extract a RAR File in Linux

To open/extract a RAR file in current working directory, just use the following command with unrar e option.

To open/extract a RAR file in specific path or destination directory, just use the unrar e option, it will extract all the files in specified destination directory.

To open/extract a RAR file with their original directory structure. just issue below command with unrar x option. It will extract according their folder structure see below output of the command.

Step 3: How to List a RAR File in Linux

To list a files inside a archive file use unrar l option. It will display the list of files with their sizes, date, time and permissions.

Step 4: How to Test a RAR File in Linux

To test an integrity of a archive file, use option unrar t. The below command will perform a complete integrity check for each file and displays the status of the file.

The unrar command is used to extract, list or test archive files only. It has no any option for creating RAR files under Linux. So, here we need to install RAR command-line utility to create archive files.

Step 5: How to Install Rar in Linux

To install RAR command option in Linux, just execute following command.

Sample Output

Step 6: How to Create Rar File in Linux

To create a archive(RAR) file in Linux, run the following command with rar a option. It will create archive file for a tecmint directory.

Step 7: How to Delete files from Archive

To delete a file from a archive file, run the command.

Step 8: How to Recover Archives

To recover or fix a archive file or files, run the command with option rar r.

Step 9: How to Update Archives

To update or add files to existing archive file, use the following command with option rar u.

Читайте также:  Math input panel windows 10 как удалить

Now, verify that the file tecmint.sql is added to archive file.

Step 10: How to Set Password to Archives

This is very interesting feature from Rar tool, it allows us to set a password to archive file. To password protect archive file use option rar a -p.

Now verify it by extracting the archive file and see whether it will prompt us to enter password that we have set above.

Step 11: How to Lock Archives

Another interesting lock feature from rar tool, it provides a option to lock a particular archive file from extracting it.

Conclusion

For mor RAR and Unrar options and usage, run the following command it will display a list of options with their description.

We have presented almost all of the options above for rar and unrar commands with their examples. If you feel that we’ve missed anything in this list and you would like us to add, please update us using comment form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

Распаковка и создание RAR архивов в Linux. Команды unrar, rar

Рассмотрим, как распаковывать и создавать RAR архивы в Linux.

Формат RAR не популярен в Linux среде. Например, штатные графические менеджеры архивов, которые используются в Linux дистрибутивах, обычно не умеют работать с RAR. Чтобы работать с такими архивами, нужно устанавливать дополнительные пакеты.

Для распаковки RAR архивов в Linux используется бесплатный пакет UNRAR от компании RARLAB.

Для создания RAR-архивов служит пакет с одноименным названием RAR. Не пугайтесь, если увидите предупреждение, что это trial-версия. На самом деле пакет не имеет ограничений на время использования. Это такая же вечная пробная версия, как и WinRAR для Windows.

Установка UNRAR

Сначала установим пакет UNRAR.

Обычно, после того, как вы установили пакет UNRAR, некоторые графические менеджеры архивов автоматически начинают поддерживать файлы в формате RAR, и вы можете распаковать их, просто щелкнув правой кнопкой по файлу в файловом менеджере и выбрав пункт Распаковать (может зависеть от дистрибутива).

Распаковка RAR-архивов

Чтобы распаковать RAR-архив, используя командную строку, выполните следующую команду (вместо archive.rar укажите путь до вашего архива). Архив будет распакован в текущую директорию.

Чтобы распаковать архив в определённую директорию (она должна существовать), укажите ее путь после имени архива (вместо ./data укажите путь до директории, в которую нужно распаковать архив):

Список файлов в архиве

Чтобы получить список файлов в архиве, используется опция l :

Протестировать архив

Чтобы убедиться, что архив «не битый», используется опция t (test). Тестируется целостность каждого файла в архиве и выводится результат для каждого файла.

Распаковать RAR с паролем

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

Другие возможности команды UNRAR

Мы рассмотрели только базовые опции. UNRAR имеет больше возможностей.

Приведем список некоторых часто используемых опций:

Опция Описание
x Распаковать архив, сохраняя структуру директорий архива.
e Распаковать архив. Структура директорий архива не сохраняется. Все файлы распаковываются в одну директорию. Если попадаются файлы с одинаковыми именами, то будет выдан запрос на перезапись/пропуск/переименование файла.
pПАРОЛЬ Указать пароль для защищенного архива (password).
l Вывести список файлов в архиве (list).
t Протестировать целостность архива (test).
cl Преобразовать имена файлов в строчные буквы (convert to lower case).
cu Преобразовать имена файлов в прописные буквы (convert to upper case).
kb Распаковывать все файлы, включая «битые» (keep broken).

Полный список всех поддерживаемых опций можно получить, выполнив:

Создание RAR архивов в Linux

Для создания RAR архивов в Linux используется пакет RAR.

Установка пакета RAR

Для установки RAR выполните команду (выберите соответствующую команду для вашего дистрибутива):

Создать RAR архив

Для создания RAR архивов используется опция a команды rar . Например, заархивируем директорию mydir в файл archive.rar :

В результате будет создан архив archive.rar , который содержит только файлы, расположенные непосредственно в директории mydir , не включая вложенные директории.

Чтобы заархивировать директорию полностью, включая все вложенные файлы и директории, используется опция -r (recursive):

Можно указать список файлов, которые нужно заархивировать:

Указать степень сжатия

Чтобы указать степень сжатия, используется опция -mЧИСЛО , для которой указывается число от 0 до 5. 0 — без сжатия, 1 — минимальное сжатие, 5 — максимальное. По умолчанию используется степень сжатия — 3. Пример создания архива с максимальной степенью сжатия:

Разбить архив на несколько файлов

Используя опцию -vРАЗМЕР можно создать архив, который будет разбит на несколько файлов. Для указания размера нужно использовать обозначения: M — мегабайты, k — килобайты, b — байты. Например, создадим архив, который разобьем на файлы размером 100 мегабайт:

Распаковать такой архив можно обычными средствами команды rar . Только в качестве архива нужно указать первый файл: rar x archive.part01.rar

Добавить файлы в архив

Чтобы добавить файлы в существующий архив, используется опция u :

Удалить файлы из архива

Rar позволяет удалять отдельные файлы из существующего архива, для этого используется опция d .

Восстановить битый архив

Если архив поврежден, то можно попытаться его восстановить, используя опцию r :

Создать архив с паролем

Чтобы создать архив, защищенный паролем, используется опция -p :

Для существующего RAR-архива также можно задать пароль:

В результате выполнения данной команды появится запрос на ввод пароля.

Распаковать архив

Команда rar , как и описанная выше команда unrar , умеет распаковывать архивы. Для распаковки архивов используется опция x :

Другие возможности команды RAR

Команда rar обладает внушительным количеством опций. Полное описание команды rar можно получить, выполнив в терминале:

Источник

Как извлечь файлы RAR в Linux

Если вы хотите извлечь файлы RAR в Linux, вам нужен пакет «Unrar».

Без этого пакета в системе невозможно вообще взаимодействовать или извлекать файлы RAR в Linux.

Rar – закрытый, проприетарный формат, и разработчики под Linux, как и сообщество в целом, не слишком заботятся о формате.

Единственная причина, по которой существуют такие инструменты, как Urar, заключается в том, что когда вы неизбежно сталкиваетесь с архивом RAR (обычно через загрузку), и вам необходимо извлечь его при использовании платформы Linux.

Установка Unrar

Установка пакета Unrar достаточно проста, так как большинство основных дистрибутивов Linux имеют программное обеспечение в своих источниках программного обеспечения.

Чтобы установить пакет Unrar, откройте окно терминала и следуйте инструкциям, которые соответствуют используемой операционной системе.

Примечание. Утилита Unrar для Linux очень хорошо работает с архивами RAR версии 3.0 или более ранней. Тем не менее, он сталкивается со значительными проблемами при работе с новым проприетарным форматом RAR (версия 5.0) и абсолютно не будет работать с файлами 5.0, пока разработчик не добавит новые функции в инструмент.

Ubuntu

Unrar довольно хорошо поддерживает Ubuntu, и программу можно найти в ее основных источниках программного обеспечения.

Чтобы получить в руки утилиту Unrar, откройте окно терминала и введите в него следующую команду Apt, чтобы начать работу.

Debian

Debian Linux имеет пакет Unrar в своих основных источниках программного обеспечения.

Чтобы заполучить его, запустите окно терминала и введите команду Apt-get.

Arch Linux

Используя Arch и нужно установить утилиту Unrar?

Попробуйте команду Pacman!

Fedora

Утилита Unrar находится в основном репозитории программного обеспечения Fedora Linux.

Чтобы установить ее, необходимо ввести команду DNF ниже:

OpenSUSE

Чтобы получить инструмент извлечения Unrar RAR в OpenSUSE, запишите эту команду Zypper в окне вашего терминала.

Извлечь файлы RAR – Терминал

Многие программы архивирования в Linux используют Unrar для извлечения файлов RAR.

Тем не менее, есть возможность взаимодействовать с Unrar и использовать его для извлечения архивных файлов непосредственно из терминала Linux.

Вот как это сделать.

Шаг 1: Найдите расположение архива (ов) RAR, который вы хотите извлечь на вашем компьютере Linux, с помощью команды locate.

Шаг 2: Запомните расположение вывода архива RAR. Или скопируйте его в буфер обмена с помощью мыши.

Шаг 3: Напишите unrar, затем переключатель e и расположение файла из шага 1.

Шаг 4: Запустите команду ls, чтобы просмотреть результат процесса извлечения.

Найдите имя папки, которая вышла из вашего архива RAR, и запишите ее

Шаг 5: Используя команду CD, переместите сеанс терминала в папку с файлами.

Шаг 6: Просмотрите элементы в папке RAR, повторно выполнив команду ls.

Источник

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

Last updated September 22, 2020 By Ankush Das 32 Comments

Looking for WinRAR in Linux? Here’s how to extract and use RAR files in Linux.

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?

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):

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:

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.

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.

Wrapping Up

Now that you’ve known how to use RAR files on Ubuntu, will you prefer using it over 7-zip, Zip, or Tar.xz?

Let us know your thoughts in the comments below.

Like what you read? Please share it with others.

About Ankush Das

A passionate technophile who also happens to be a Computer Science graduate. You will usually see cats dancing to the beautiful tunes sung by him.

# I’ve made this simple python3 script to extract a file from a .rar file
# and put the data into a folder with the same name of the file in the curent directory.

# The script is very simple, it’s just a quick help if you are interested.

# It has some limitations:
# 1) I renamed the .rar file to be able to execute the program
# 2) It only extract one .rar file at the time

# Requisites:
# * you need to install the unrar program
# JUST RUN: sudo apt install unrar -y

# To run the code, just type:

# python3
# Example: python3 rar-extract.py file_to_extract.rar

import os
import sys

# rename rar file to remove spaces from the name
raw_argv = sys.argv[1]
argv_ws = raw_argv.replace(” “,”_”)
os.rename(sys.argv[1],argv_ws)

#remove the .rar extension from the file
#it will be used to create a new folder
arg = (argv_ws.split(“.”)[0]).replace(” “,”_”)

#create the new folder
current_directory = os.getcwd()
final_directory = os.path.join(current_directory, arg)
if not os.path.exists(final_directory):
os.makedirs(final_directory)

#path to the new flder
path = current_directory +”/”+ arg

#enter the new folder
os.system(“cd ” + path)

# command line to extract the file
terminal_line = “unrar e ” + str(argv_ws) + ” ” + path

Источник

Читайте также:  Виндовс медиаплеер для windows 10
Оцените статью