Extract from archive linux

Содержание
  1. How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux
  2. Extract .zip file in Linux
  3. Extract .gz file in Linux
  4. Extract .tar file in Linux
  5. Extract .tar.gz file in Linux
  6. Extract .tar.xz file in Linux
  7. Extract .tar.bz2 file in Linux
  8. Extract .7z file in Linux
  9. Extract .rar file in Linux
  10. How to Extract Tar Files to Specific or Different Directory in Linux
  11. Example 1: Extracting tar Files to a Specific Directory
  12. Example 2: Extract .tar.gz or .tgz Files to Different Directory
  13. Example 3: Extract tar.bz2, .tar.bz, .tbz or .tbz2 Files to Different Directory
  14. Example 4: Extract Only Specific or Selected Files from Tar Archive
  15. Summary
  16. If You Appreciate What We Do Here On TecMint, You Should Consider:
  17. How to Open, Extract and Create RAR Files in Linux
  18. Step 1: How to Install Unrar in Linux
  19. Step 2: How to Open/Extract a RAR File in Linux
  20. Step 3: How to List a RAR File in Linux
  21. Step 4: How to Test a RAR File in Linux
  22. Step 5: How to Install Rar in Linux
  23. Step 6: How to Create Rar File in Linux
  24. Step 7: How to Delete files from Archive
  25. Step 8: How to Recover Archives
  26. Step 9: How to Update Archives
  27. Step 10: How to Set Password to Archives
  28. Step 11: How to Lock Archives
  29. Conclusion
  30. If You Appreciate What We Do Here On TecMint, You Should Consider:
  31. Команда tar в Linux
  32. Синтаксис команды tar
  33. Как пользоваться tar
  34. 1. Создание архива tar
  35. 2. Просмотр содержимого архива
  36. 3. Распаковка архива tar Linux
  37. 3. Работа со сжатыми архивами
  38. Выводы

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

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.

Читайте также:  Восстановление системы windows что это значит

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 Extract Tar Files to Specific or Different Directory in Linux

The tar utility is one of the utilities that you can use to create a backup on a Linux system. It includes many options that one can use to specify the task to achieve.

Extract Linux Tar Files Different or New Directory

One thing to understand is that you can extract tar files to a different or specific directory, not necessarily the current working directory. You can read more about tar backup utility with many different examples in the following article, before proceeding further with this article.

In this guide, we shall take a look at how to extract tar files to a specific or different directory, where you want the files to reside.

The general syntax of tar utility for extracting files:

Note: In the above first syntax, the -C option is used to specify a different directory other than the current working directory.

Let us now look at some examples below.

Example 1: Extracting tar Files to a Specific Directory

In the first example, I will extract the files in articles.tar to a directory /tmp/my_article . Always make sure that the directory into which you want to extract tar file exists.

Let me start by creating the /tmp/my_article directory using the command below:

You can include the -p option to the above command so that the command does not complain.

To extract the files in articles.tar to /tmp/my_article , I will run the command bellow:

Img 01: Extract Tar Files to Different Directory

In the above example I used the -v option to monitor the progress of the tar extraction.

Let me also use the —directory option instead of -c for the example above. It works just in the same way.

Img 02: Extract Tar Files to Specific Directory

Example 2: Extract .tar.gz or .tgz Files to Different Directory

First make sure that you create the specific directory that you want to extract into by using:

Now we will extract the contents of documents.tgz file to separate /tmp/tgz/ directory.

Img 03: Extract tar.gz or .tgz Files to Different Directory

Example 3: Extract tar.bz2, .tar.bz, .tbz or .tbz2 Files to Different Directory

Again repeating that you must create a separate directory before unpacking files:

Now we will be unpacking the documents.tbz2 files to /tmp/tar.bz2/ directory.

Img 04: Extract tar.bz2 Files to Different Directory

Example 4: Extract Only Specific or Selected Files from Tar Archive

The tar utility also allows you to define the files that you want to only extract from a .tar file. In the next example, I will extract specific files out of a tar file to a specific directory as follows:

Img 05: Extract Specific Files From Tar Archive

Summary

That is it with extracting tar files to a specific directory and also extracting specific files from a tar file. If you find this guide helpful or have more information or additional ideas, you can give me a feedback by posting a comment.

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.

Источник

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.

Читайте также:  Command line windows server version

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.

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.

Читайте также:  Send email windows live

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.

Источник

Команда tar в Linux

В качестве инструмента для архивации данных в Linux используются разные программы. Например архиватор Zip Linux, приобретший большую популярность из-за совместимости с ОС Windows. Но это не стандартная для системы программа. Поэтому хотелось бы осветить команду tar Linux — встроенный архиватор.

Изначально tar использовалась для архивации данных на ленточных устройствах. Но также она позволяет записывать вывод в файл, и этот способ стал широко применяться в Linux по своему назначению. Здесь будут рассмотрены самые распространенные варианты работы с этой утилитой.

Синтаксис команды tar

Синтаксис команд для создания и распаковки архива практически не отличается (в том числе с утилитами сжатия bzip2 или gzip). Так, чтобы создать новый архив, в терминале используется следующая конструкция:

tar опции архив.tar файлы_для_архивации

Для его распаковки:

tar опции архив.tar

Функции, которые может выполнять команда:

Функция Длинный
формат
Описание
-A —concatenate Присоединить существующий архив к другому
-c —create Создать новый архив
-d —diff
—delete
Проверить различие между архивами
Удалить из существующего архива файл
-r —append Присоединить файлы к концу архива
-t —list Сформировать список содержимого архива
-u —update Обновить архив более новыми файлами с тем же именем
-x —extract Извлечь файлы из архива

При определении каждой функции используются параметры, которые регламентируют выполнение конкретных операций с tar-архивом:

Параметр Длиннный
формат
Описание
-C dir —directory=DIR Сменить директорию перед выполнением операции на dir
-f file —file Вывести результат в файл (или на устройство) file
-j —bzip2 Перенаправить вывод в команду bzip2
-p —same-permissions Сохранить все права доступа к файлу
-v —verbose Выводить подробную информацию процесса
—totals Выводить итоговую информацию завершенного процесса
-z —gzip Перенаправить вывод в команду gzip

А дальше рассмотрим примеры того, как может применяться команда tar Linux.

Как пользоваться tar

1. Создание архива tar

С помощью следующей команды создается архив archive.tar с подробным выводом информации, включающий файлы file1, file2 и file3:

tar —totals —create —verbose —file archive.tar file1 file2 file3

Но длинные опции и параметры можно заменить (при возможности) однобуквенными значениями:

tar —totals -cvf archive.tar file1 file2 file3

2. Просмотр содержимого архива

Следующая команда выводит содержимое архива, не распаковывая его:

tar -tf archive.tar

3. Распаковка архива tar Linux

Распаковывает архив test.tar с выводом файлов на экран:

tar -xvf archive.tar

Чтобы сделать это в другой каталог, можно воспользоваться параметром -C:

tar -C «Test» -xvf archive.tar

3. Работа со сжатыми архивами

Следует помнить, что tar только создаёт архив, но не сжимает. Для этого используются упомянутые компрессорные утилиты bzip2 и gzip. Файлы, сжатые с их помощью, имеют соответствующие расширения .tar.bz2 и .tar.gz. Чтобы создать сжатый архив с помощью bzip2, введите:

tar -cjvf archive.tar.bz2 file1 file2 file3

Синтаксис для gzip отличается одной буквой в параметрах, и меняется окончание расширения архива:

tar -czvf archive.tar.gz file1 file2 file3

При распаковке tar-архивов с таким расширением следует указывать соответствующую опцию:

tar -C «Test» -xjvf arhive.tar.bz2

tar -xzvf archive.tar.gz

На заметку: архиватор tar — одна из немногих утилит в GNU/Linux, в которой перед использованием однобуквенных параметров, стоящих вместе, можно не ставить знак дефиса.

Выводы

В этой статье была рассмотрена команда tar Linux, которая используется для архивации файлов и поставляется по умолчанию во всех дистрибутивах. В её возможности входит создание и распаковка архива файлов без их сжатия. Для сжатия утилита применяется в связке с популярными компрессорами bzip2 и gzip.

Источник

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