GNU/Linux >> Linux の 問題 >  >> Ubuntu

ubuntulinuxでtar.gzファイルとtar.bz2ファイルを作成して抽出します

Linuxで最も一般的な圧縮アーカイブファイル形式はtar.gz形式です。 tarファイルはアーカイブファイル形式です。 Tar.gzは圧縮されたtarファイルです。

tar.gzアーカイブを作成する

tarコマンドを使用してtar.gzアーカイブを作成できます。

tar czf new-tar-file-name.tar.gz file-or-folder-to-archive

コマンドの説明は次のとおりです。

c - create new archive.
z - compress the archive using gzip.
f - use archive file.
new-tar-file-name.tar.gz - the name of the tar.gz to create.
file-or-folder-to-archive - the name of the folder we want to archive.

複数のディレクトリを追加する

tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2

tarアーカイブを抽出する

gzアーカイブ

tar -xzf tar-file-name.tar.gz

コマンドの説明は次のとおりです。

x - extract the archive.
z - uncompress the archive using gzip.
f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.

tarコマンドは、アーカイブ内のすべてのファイル/フォルダーを現在のディレクトリに抽出します。特定の場所に抽出するには、次のようにコマンドを変更します

tar -xzf tar-file-name.tar.gz /path/to/location

bz2アーカイブ

tar.bz2(bzip2ファイル)の抽出は、tar.gzファイルの抽出方法と非常によく似ています。 -zフラグを使用する代わりに、bzip2形式の-jフラグを使用する必要があります

tar -xvjf tar-file-name.tar.gz

コマンドの説明は次のとおりです。

x - extract the archive.
v - verbose. show information as files are being extracted.
j - filter the archive through bzip2
f - use archive file.
tar-file-name.tar.gz - the name of the tar.gz to create.

tarコマンドは、アーカイブ内のすべてのファイル/フォルダーを現在のディレクトリに抽出します。


Ubuntu
  1. Linuxでファイルを圧縮および抽出するための16のtarコマンド

  2. Linuxで.gzファイルと.tar.gzファイルを抽出する方法

  3. Linuxでのtarコマンド(ファイルの圧縮と解凍)

  1. アーカイブを作成および抽出するためのLinuxでの10のtarコマンドの例

  2. Linuxでtarコマンドを使用してファイルを圧縮および抽出する方法は?

  3. Ubuntuでスワップファイルを作成および削除する

  1. UbuntuLinuxのVirtualBoxでVMスナップショットを作成して復元する

  2. Linux cpio の例:cpio アーカイブ (および tar アーカイブ) を作成および抽出する方法

  3. Linux で gzip と bzip2 を使用してファイルとディレクトリを圧縮および抽出する方法