How to unzip linux bz2

Как распаковать 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

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

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

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

Читайте также:  Ntp linux синхронизация времени сервером

Очень просто. Нажимаем правой кнопкой мыши на значок архива, появляется контекстное меню и в нем есть кнопка «Распаковать» (способ подходит для файловых менеджеров 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 or Unzip Tar Bz2 (.tar.bz2 | .tbz2) Files on Ubuntu Linux

This brief tutorial shows students and new users how to extract or unzip archived tar files compressed with bzip2 compression ending in .tar.bz2 or .tbz2 on Ubuntu 18.04 LTS.

The tar command creates, maintains, and extracts files archived in tar format on Linux systems, including Ubuntu. “Tar” stands for tape archive.

If you’re a student or new user looking for a Linux system to start learning on, the most accessible place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

About tar command:

The tar command creates, maintains, and extracts files archived in tar format on Linux systems, including Ubuntu. “Tar” stands for tape archive. It is one of the many archiving file formats available.

Читайте также:  Распаковка tar xz linux консоль

The syntax is the rule and format of how the tar command can be used. These syntax options can be reordered, but a straight format must be followed.

Below is an example syntax of how to use the tar command.

tar [OPTION.] [FILE].

The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the commands. They are separated by spaces and followed after the commands.

Below are some options for the tar command:

FILE. Replace FILE.. with the name of the archived file you want to extract.
-x, –extract, –get
Use the -x or –extract or –get to extract files from an archive
-f, –file=ARCHIVE Use the -f or –file to specify the use of archive file to extract
-v, –verbose Use the -v or –verbose to verbosely list files being processed
-j, –bzip2 Use the -j or –bzip2 to filter the archive through bzip2 compression
-t, –list Use the -t or -list to list the content of an archive
–help Display a help message and exit.

Below are some examples of how to run and use the tar on Ubuntu Linux.

Simply run the tar command to invoke it.

To extract a tar archive file compressed with the bz2 compression algorithm, you run the command below:

The command above will extract the archive file into the current working directory. The -j option tells tar that the file is compressed with bzip2.

A file is compressed with .tar.bz2, and you run the tar command without a decompression option; the command will error out and tells you to use the -j option for it to be successful.

If you wish to extract the above-archived file into a specific directory, you run the commands below:

tar -xvjf archive.tar.bz2 -C /home/myaccount/public

The command above will extract the archive file into the /home/myaccount/public directory or folder.

Suppose you want to list the content of an archived file compressed with tar.bz2, you use the -t or –list command options.

That should list the content of the archive. Always use the -f option to tell the command you’re working with a file archive.

When you run su with the –help option, you’ll see the help text below:

Usage: tar [OPTION.] [FILE]. GNU 'tar' saves many files together into a single tape or disk archive, and can restore individual files from the archive. Examples: tar -cf archive.tar foo bar # Create archive.tar from files foo and bar. tar -tvf archive.tar # List all files in archive.tar verbosely. tar -xf archive.tar # Extract all files from archive.tar. Local file name selection: --add-file=FILE add given FILE to the archive (useful if its name

Congratulations! You’ve learned to use the tar command to extract archived compressed with .tar.bz2 or .tar.bzip2 on Ubuntu.

Читайте также:  Linux вывести последние строки лога

You may also like the commands below:

Richard W

I love computers; maybe way too much. What I learned I try to share at geekrewind.com.

Источник

How to Extract a Tar.bz2 File

A “tar.bz2” file is a compressed archive file created using the tar command in Unix/Linux and the bzip2 compression algorithm. It is commonly used for distributing large files or groups of files as a single archive, which is smaller in size compared to the original files, making it easier to transfer and manage.

The tar command is used to create an archive of multiple files or directories and the bzip2 compression algorithm is used to reduce the size of the archive. The resulting archive file has a .tar.bz2 extension and can be unpacked using the tar command with the -j option.

We can unzip a .tar.bz2 file using Linux tar command. In this tutorial, you will learn the followings:

  • How to Unzip tar.bz2 file
  • How to Create tar.bz2 compressed file
  • Command to list the content of tar.bz2 without extracting it

How to Unzip tar.bz2 file

You can use Linux tar command with option -j to extract bz2 file. As this is a also tar compressed file, You also need to use -x command line option.

So we can use -xjf options with the tar command to extract a .tar.bz2 file:

The above command will extract tar.bz2 file content in current directory.

To extract files in a defend location, use -C option followed by the destination directory.

tar -xvjf filename.tar.bz2 -C /opt 

Now all the files will be extracted under /opt directory.

How to create tar.bz2 file

The tar command uses -c to create a compressed tar archive file. You can also use -j to create a tar.bz2 archive file.

For example, to create a backup of your web server directory, execute:

tar -cjf backup.tar.bz2 /var/www/html 

The above command will compress all the files available under /var/www/html directory and create backup.tar.bz2 compressed file in current directory.

How to list tar.bz2 content without extract

You never need to extract a archive file to just view the file content. Use -t with -v (verbose) command line option to list archive file content only.

Output
drwxr-xr-x root/root 0 2023-02-01 11:54 var/www/html/ drwxr-xr-x root/root 0 2023-02-01 11:54 var/www/html/static/ drwxr-xr-x root/root 0 2023-02-01 11:55 var/www/html/static/js/ -rw-r--r-- root/root 14150 2023-02-01 11:55 var/www/html/static/js/main.js drwxr-xr-x root/root 0 2023-02-01 11:55 var/www/html/static/css/ -rw-r--r-- root/root 14149 2023-02-01 11:55 var/www/html/static/css/main.css -rw-r--r-- root/root 10701 2023-01-31 11:01 var/www/html/index.html

Conclusion

An archive file are useful for creating backups, making bundle of files and save disk space. In this tutorial, you have learned how to extract a .tar.bz2 file using command line. Additionally, you learned to create .tar.bz2 file or list files without extracting it.

Источник

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