Linux tar unzip tar gz

Как распаковать tar bz2 xz gz архивы в Linux

Для распаковки tar-архивов через командную строку используется утилита tar.

Полезно знать, что архивы в формате tar имеют расширение файлов .tar . Также в Linux распространены архивы, которые имеют дополнительное сжатие другими программами. Например, архивы .tar.bz2 , .tar.gz и другие. Все эти архивы можно распаковать утилитой tar.

Распаковка tar

Для распаковки архива в формате .tar в текущую директорию выполните команду:

Распаковка tar.bz2, tar.bzip2, tbz2, tb2, tbz

Распаковка tar.xz, txz

Распаковка tar.gz, tgz

Распаковка tar.lzma

tar --lzma -xvf archive.tar.lzma

Пояснение опций

x — распаковать архив.
v — Verbose-режим (вывод на экран дополнительной информации во время распаковки).
f — выполнить распаковку архива из файла.
j — вызвать bzip2 для распаковки архива.
z — вызвать gzip
J — вызвать xz

Распаковка в определенную директорию

Чтобы распаковать архив в определенную директорию используется опция -C или —directory , например:

tar xvf archive.tar -C /to/directory

Примечание: директория должна существовать.

Заключение

Мы рассмотрели базовый набор команд, который можно использовать для распаковки различных видов tar-архивов. Существуют также еще некоторые типы архивов, но они менее распространены.

Смотрите также

  • Gentoo
  • GNOME
  • GRUB
  • Ubuntu
  • Внешний вид
  • Игры Linux
  • Интернет и сети
  • Командная строка
  • Настройка Linux
  • Оборудование и драйвера
  • Программы Linux
  • Файловая система
  • Шрифты
  • Общие темы
  • Руководство по Ubuntu Linux для начинающих
  • Elementary OS
  • ArchLinux
  • Команды Linux

Новое в галерее

Новые комментарии

Комментарии

Постоянная ссылка на комментарий

Постоянная ссылка на комментарий

Постоянная ссылка на комментарий

Постоянная ссылка на комментарий

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

Постоянная ссылка на комментарий

Постоянная ссылка на комментарий

-a, —auto-compress
Use archive suffix to determine the compression program.

Постоянная ссылка на комментарий Родительский комментарий aNDy

Ключ -a работает при создании архивов, например

tar -cvaf doc.tar.xz ~/Documents/

Тут главное не ошибиться с расширением. Например, если указать «.tar.bz» — создастся обычный tar без сжатия («.tar.bz2» — Ok)
Возможно, именно поэтому в своё время мне показалось, что оно меня игнорирует, и я решил, что это ключ для распаковки : )

Читайте также:  Чем линукс лучше программистам

А для распаковки дискового файла с правильным расширением достаточно просто

без указания метода сжатия.

Проверено для gz, bz2, xz, lz, lzma

Постоянная ссылка на комментарий

Юрий было бы не плохо опубликовать статью про температуру процессора, как её регулировать, или как она регулирается и т.п., много вопросов и мало ответов.

Постоянная ссылка на комментарий

Очень просто. Нажимаем правой кнопкой мыши на значок архива, появляется контекстное меню и в нем есть кнопка «Распаковать» (способ подходит для файловых менеджеров Dolphin и Thunar)

Постоянная ссылка на комментарий Родительский комментарий KittyBlanc

$ wget http://linux.palemoon.org/datastore/release/palemoon-unstable-latest.linux-x86_64-gtk2.tar.xz -qO- | tar -xvJ

Как сделать в Dolphin или Thunar?

Постоянная ссылка на комментарий Родительский комментарий aNDy

Постоянная ссылка на комментарий Родительский комментарий KittyBlanc

Врёшь. Не написал.
Нет ничего про распаковку скачиваемого потока.

Постоянная ссылка на комментарий Родительский комментарий aNDy

Постоянная ссылка на комментарий

Кхе кхе, прошу прощения в графическом режиме уже запретили?! огонь добывать с помощью палки и камня прикажите?

Постоянная ссылка на комментарий Родительский комментарий Незнайка

Постоянная ссылка на комментарий

unpack () <
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xjfv $1 ;;
*.tar.gz) tar xzfv $1 ;;
*.tar.xz) tar xvJf $1 ;;
*.bz2) bunzip2 $1 ;;
*.gz) gunzip $1 ;;
*.rar) unrar x $1 ;;
*.tar) tar xf $1 ;;
*.tbz) tar xjvf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo «I don’t know how to extract ‘$1′» ;;
esac
else
case $1 in
*help) echo «Usage: unpack ARCHIVE_NAME» ;;
*) echo «‘$1’ is not a valid file» ;;
esac
fi
>
# function to create archives
# EXAMPLE: pack tar file
pack () <
if [ $1 ]; then
case $1 in
tar.bz2) tar -cjvf $2.tar.bz2 $2 ;;
tar.gz) tar -czvf $2.tar.bz2 $2 ;;
tar.xz) tar -cf — $2 | xz -9 -c — > $2.tar.xz ;;
bz2) bzip $2 ;;
gz) gzip -c -9 -n $2 > $2.gz ;;
tar) tar cpvf $2.tar $2 ;;
tbz) tar cjvf $2.tar.bz2 $2 ;;
tgz) tar czvf $2.tar.gz $2 ;;
zip) zip -r $2.zip $2 ;;
7z) 7z a $2.7z $2 ;;
*help) echo «Usage: pack TYPE FILES» ;;
*) echo «‘$1’ cannot be packed via pack()» ;;
esac
else
echo «‘$1’ is not a valid file»
fi
>

Источник

How to Extract Tar Gz File in Linux — [Untar tar.gz]

This blog post will help you to get information about how to unzip tar.gz file, untar tar.gz file, and extract tar GZ file in Linux? Also, you can get a detailed guide to executing the overall process.

Читайте также:  Linux поменять mac адрес

How to Extract Tar Gz File in Linux - [Untar tar.gz]

List of content you will read in this article:

What is TAR? [Definition]

TAR is an abbreviation for Tape ARchive. This command was primarily developed to fulfill the purpose of creating archives and storing the files on magnetic tape. Hence, the name Tape Archive.

The tar command helps you to generate several tar archives as it converts as many files as you want into archives. When we talk about the tar command, it can be used in ample ways. You can use it to add files to the archive, delete files, or extract tar archives. The list is pretty long.

Being a techie, it is highly evident that you are already familiar with the .tar.gz files.

These files are commonly known as ‘tarballs’. They are used by Linux, macOS, or even Windows users for backups or data archival.

Now, there are various methods to compress tar files. One of the most used methods to compress a file is Gzip. Moreover, whenever you compress the tar archive with gzip, it ends with .tar.gz or .tgz extension.

Besides, if you are a Windows user, you may need to download the 7zip tool to extract tar.gz file in Linux. A lot of such third-party applications are also available in the market. They do come with a drawback, that is, they do not work every time.

In this article, we are going to make you familiar with some ways to unzip/untar/extract tar.gz archives in both Linux and Windows.

How to extract tar.gz file in Linux?

It is a simple process to extract tar.gz file in Linux.

Before that, take a look at the meaning of these symbols:

1. x: This option is used to extract the files.

2. v: It means Verbose. It helps to list the files in the archive.

3. z: This is used to uncompress a file.

4. f: You can easily keep a name for the file by using this option.

To start with, if the file is compressed by a gzip compressor, you can apply the following command:

In this command, filename.tar.gz is the name of the archive that you want to unpack tar.gz file. Additionally, if you want to seek more information about the files, you may use the -v option. Here, -v stands for Verbose. Take a look:

Easy, right? But somehow if your work impedes and you don’t get the desired results, follow another method.

Читайте также:  Linux resize root partition ext4

How to unzip .tar.gz file without gzip?

Follow the below-given procedure to unzip .ta.gz file without gzip command.

$ tar xvzf file.tar.gz -C /path/to/somedirectory

Here, -C is used to mention the particular path to store the file.

  • The next command is to extract a .doc file from the .tar.gz file. Take a look at the command below:

$ tar -xvzf file.tar.gz test.doc

tar -xf archive.tar.gz file1 file2

  • This command is specifically used for files. If you want to extract some directories, use the following command:

tar -xf archive.tar.gz dir1 dir2

Sometimes you get an error message like this:

tar -xf archive.tar.gz README

It implies that the files that you want to extract don’t exist.

  • Moving on, if you want to list the content of your tar.gz file, then use the below-mentioned command:

Well, these were some of the commands to extract tar.gz files in Linux.

The next segment talks to you about extracting tar.gz files in Windows. Let’s see how!

How to untar tar.gz files in Windows?

If you are a Windows user, here are a few steps for you to follow so that you can easily extract/untar tar gz file.

Step 1. Tap on Start on your Windows

Step 2. Now, go to the Command Prompt and click right. Choose Run as Administrator option

Step 3. Enter this command in the command prompt: tar -xvzf C:\PATH\TO\FILE\FILE-NAME.tar.gz -C C:\PATH\TO\FOLDER\EXTRACTION

You can add any desired path to store your files. After you press enter, all the files will be extracted to the path that you mention.

If you do not wish to use the command line method, don’t worry. There is another solution. You can simply head towards the File manager and click right on the file that you wish to extract. Choose the Extract option.

Conclusion

In a nutshell, tar.gz files or tarballs are used to archive data and backups. It is necessary to decompress and extract these files in order to get your work going.

There are specific ways and methods to conclude your task through various steps and commands.

As you have seen, this article assists you to extract tar.gz file [unzip tar.gz file, untar tar.gz file], whether you are a user of Linux or Windows.

We hope that the information provided in this article helps you in the best possible way.

Keep learning. Keep evolving.

People are also reading:

Источник

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