Linux extract rar archive

How to Extract (Open) a RAR File in Linux

RAR is a file format used for data compression and archiving. The RAR format supports data compression, error recovery and files archives. It also supports files larger than 4 gigabytes. RAR files can only be created through commercial software. You can extract rar file using free unRAR command line tool in Linux.

By default, unRAR is not being installed on Linux or UNIX distro. You need to install unRAR/rar tools with the help of below linux commands.

Install unrar/rar tool

If you are using Redhat Linux or Centos, then use yum command as follows to install unRAR command.

Listed below are some practical examples of RAR and unRAR command in linux to open,extract and compress files.

1. Extract (open) rar file

If you want to extract all files within the ‘.rar’ file in the current directory run below command

2. Extract files with full path

If you want to extract the files in full path. Run below command

3. List content of a RAR file

To list files inside rar archive file without extracting. Then use ‘l’ option

4. Check archive integrity

To test the integrity of file archive use ‘t’ option

5. Create a rar single file

To create a .rar archive file use ‘a’ option.

6. Create multiple rar files

To compress say ‘file1′, ‘file2′ and ‘file3′ simultaneously, use below command

You can also use the following method to RAR multiple files.

7. Set password for RAR file

While archiving, you can set a password (using -p option). If you omit the password on the command line, you will be prompted with a message “enter password” and the password is case sensitive.

Conclusion

In this tutorial we learned how to use rar/unrar command in linux to open,extract and create rar files. Hope you enjoyed reading this and please leave your comments below.

Источник

How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux

An archive file is a file composed of one or more files in compressed format. It’s useful for saving disk storage, managing a single file is easier than managing multiple files. This tutorial will help you to decompress or extract an archive file in the Linux system via command line. You can also list archive file content without extracting it.

Extract .zip file in Linux

This is the most common compression format used by various IT professions on many operating systems. For this you must of unzip binary installed on your system.

Extract .gz file in Linux

Gz files are compressed files created using the Gzip compression utility. In general, GZIP is better compared to ZIP, in terms of compression, especially when compressing a huge number of files. Use gunzip command to extract .gz archive file.

Extract .tar file in Linux

Tar is the sort of Tape Archive and also referred to as the tarball. This is another popular archiving method which is also known as the consolidated Unix archive format. To extract .tar file use following command

Читайте также:  Отключение трея windows 10

Extract .tar.gz file in Linux

TAR.GZ file is a combination of TAR and GZIP archives. If provides more compression format of data. You can use -z switch to extract these files.

Extract .tar.xz file in Linux

The XZ format is a single file compression format and does not offer archiving capabilities. It preserves the original data with no loss in quality. You can use -J switch to extract these files.

Extract .tar.bz2 file in Linux

Tar.bz2 is an combination of tar and bzip2 archive formats. You can use -j to filter the archive through bzip2. Use the following to extract .tar.bz2 compressed file.

The latest version fo tar automatically detects the archive format. So you can simply use the following command.

Extract .7z file in Linux

These files are 7zip archive files. This is not generally used on Linux systems, but sometimes you may need to extract some source files. You must have the 7zip package installed on your system. Use the following command to extract these files.

Extract .rar file in Linux

These are common archive format for Windows systems, but Linux users avoid to use this. Still you may need sometimes to extract .rar file on Linux. You can use 7z command to extract this or unrar.

Источник

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.

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.

Читайте также:  Как отключить hdr windows

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

В операционной системе 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

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

unrar l file.rar

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

unrar x file.rar

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

unrar t file.rar

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

unrar e file.rar

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

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

Выводы

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

Источник

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.

Читайте также:  Windows cannot complete assessment

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

Источник

Оцените статью