Create rar archive 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 Archive Ubuntu
  34. Installing rar package
  35. Creating archive file
  36. Showing the content of archive file
  37. Extracting archive file
  38. Creating and extracting password protected archive file
  39. About the author
  40. Fahmida Yesmin

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.

Читайте также:  Нет звука с линейного входа компа windows 10

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.

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 укажите путь до директории, в которую нужно распаковать архив):

Читайте также:  Windows выдает ошибку жесткий диск поврежден

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

Чтобы получить список файлов в архиве, используется опция 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 Archive Ubuntu

To compress, archive and transfer large files or folders, rar package can be used on Ubuntu. Rar is a common archiving software to compress large files or folders. Suppose, if you want to transfer a folder from one location to another location which contains many files and folders, then the first option is to compress the folder and create an archive file. The compress file can be easily attached with email or transferred to other location. Many options are available on Ubuntu to compress files or folders. But if the files and folders are compressed using rar command then the created rar file can also be extracted on windows. Because rar files are also supported by windows. How you can install and use rar package to compress or decompress files and folder is shown in this tutorial.

Installing rar package

Rar package is not installed on Ubuntu by default. So, run the following command to install rar on Ubuntu.

Rar package has various commands for creating archive files and folder. To get the list of rar commands just run rar without any command.

The following output shows that trial version of RAR 5.40 is installed on the system. You can use any command from the list with rar for the particular purpose. Use of some basic commands of rar are shown in this tutorial.

Creating archive file

Select any large file or folder to compress and create archive file using rar command. In the following example, code folder is selected to create the archive file. code folder contains 7 files and the size of code folder is 4096 bytes.

To add the file into archive, a command is used with rar and next type the name of rar file and the name of the file or folder that you want to compress. Run the command to create the archive file, code.rar file by compressing code folder.

After compression, the size of code.rar file is 1600 bytes. Run the following command to check the size of the code folder and the archive file.

Showing the content of archive file

Rar uses l command to show files and folder list of archive file. Run the following command to show the content of code.rar file.

Extracting archive file

Move code.rar folder in different location. Suppose, the archive file is moved in mydir folder. x command is used with rar to extract the archive file. Run the following command to extract the file in the current location. When code.rar file will extract then code folder will be created after extraction.

Now, run ls -la command to check the folder is created or not after extraction.

Creating and extracting password protected archive file

To create password protected archive, rar uses -p option with a command. After running the command, you have to set the same password for two times to create password protected archive file. The following command will create password protected archive file, pcode.rar of the folder code.

Now, if you want to extract pcode.rar file then it will ask for the password which is set during the archive file creation. After setting the password, type a to use current password for all files and folders of the archive file.

The above command shows the mostly used commands of rar to create and extract any archive file. There are many other uses of rar, such as, recovering archive, updating archive, locking archive, setting archive comments, deleting archive etc.

About the author

Fahmida Yesmin

I am a trainer of web programming courses. I like to write article or tutorial on various IT topics. I have a YouTube channel where many types of tutorials based on Ubuntu, Windows, Word, Excel, WordPress, Magento, Laravel etc. are published: Tutorials4u Help.

Источник

Читайте также:  Windows 2007 год выпуска
Оцените статью