124
125

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【メモ】Linux圧縮/解凍コマンド

Last updated at Posted at 2016-08-02

このドキュメントでは、Linuxで一般的に使用される圧縮・解凍コマンドの一覧を紹介します。

コマンドオプションの説明

tar コマンドのオプション

  • -x: 解凍(extract)
  • -c: 圧縮(create)
  • -v: 詳細表示(verbose)
  • -f: ファイル名指定(file)
  • -z: gzip形式の圧縮/解凍
  • -j: bzip2形式の圧縮/解凍
  • -J: xz形式の圧縮/解凍

解凍コマンド例

解凍対象ファイルの拡張子 コマンド 備考
.tar tar -xvf ファイル名 アーカイブのみ(圧縮なし)
.tar.gz .tgz tar -xzvf ファイル名 gzip圧縮されたtarアーカイブ
.tar.bz2 .tbz tar -xjvf ファイル名 bzip2圧縮されたtarアーカイブ
.tar.xz tar -xJvf ファイル名 xz圧縮されたtarアーカイブ
.gz gunzip ファイル名 または gzip -d ファイル名 単一ファイルのgzip圧縮
.bz2 bzip2 -d ファイル名 または bunzip2 ファイル名 単一ファイルのbzip2圧縮
.xz xz -d ファイル名 または unxz ファイル名 単一ファイルのxz圧縮
.lha .lzh lha x ファイル名 LHAアーカイブ(要インストール)
.zip unzip ファイル名 ZIPアーカイブ
.rar unrar x ファイル名 RARアーカイブ(要インストール)
.7z 7z x ファイル名 7-Zipアーカイブ(要インストール)

圧縮コマンド例

圧縮対象ファイルの拡張子 コマンド 備考
.tar tar -cvf ファイル名.tar ファイル名またはディレクトリ アーカイブのみ(圧縮なし)
.tar.gz .tgz tar -zcvf ファイル名.tar.gz ファイル名またはディレクトリ gzip圧縮のtarアーカイブ
.tar.bz2 .tbz tar -jcvf ファイル名.tar.bz2 ファイル名またはディレクトリ bzip2圧縮のtarアーカイブ(高圧縮率)
.tar.xz tar -Jcvf ファイル名.tar.xz ファイル名またはディレクトリ xz圧縮のtarアーカイブ(最高圧縮率)
.gz gzip ファイル名 単一ファイルの圧縮(元ファイルは削除)
.bz2 bzip2 ファイル名 単一ファイルの圧縮(元ファイルは削除)
.xz xz ファイル名 単一ファイルの圧縮(元ファイルは削除)
.lha .lzh lha c ファイル名.lzh ファイル名またはディレクトリ LHAアーカイブ(要インストール)
.zip zip -r ファイル名.zip ファイル名またはディレクトリ ZIPアーカイブ(-rはディレクトリを再帰的に圧縮)
.rar rar a ファイル名.rar ファイル名またはディレクトリ RARアーカイブ(要インストール)
.7z 7z a ファイル名.7z ファイル名またはディレクトリ 7-Zipアーカイブ(要インストール)

注意事項

  • 一部のコマンド(lha, unrar, rar, 7z)は標準でインストールされていない場合があります。必要に応じてパッケージマネージャーでインストールしてください。

    • Debian/Ubuntu: apt-get install lhasa rar unrar p7zip-full
    • CentOS/RHEL: yum install lha unrar p7zip p7zip-plugins
  • 圧縮率と処理速度の一般的な関係:

    • 高速・低圧縮率: gzip
    • 中速・中圧縮率: bzip2
    • 低速・高圧縮率: xz
124
125
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
124
125

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?