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

Linuxで圧縮/解凍する方法

Linuxには、ファイルを圧縮してアーカイブを抽出するためのツールがいくつかあります。以下の表にそれらのいくつかをリストすることができます。最初のテーブルには解凍コマンドがあります:

解凍コマンド 情報
gzip -d file.php.gz
gunzip file.php.gz
gzipユーティリティで作成されたアーカイブを抽出します。
bzip2 -d file.php.bz2
bunzip2 file.php.bz2
bzip2ユーティリティで作成されたアーカイブを抽出します。
archive.zipを解凍 zipユーティリティで作成されたアーカイブを抽出します。
tar -zxvf archivefile.tgz
tar -jxvf archivefile.tbz2
tar + gzip/bzip2で作成されたアーカイブを抽出します。
-gzip解凍の場合はz; -bzip2解凍の場合はj

各コマンドのシステム情報を表示するには、 commandname --helpと入力します。 ターミナルで:

root@web [~]# gzip --help
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.

  -c, --stdout      write on standard output, keep original files unchanged
  -d, --decompress  decompress
  -f, --force       force overwrite of output file and compress links
  -h, --help        give this help
  -l, --list        list compressed file contents
  -L, --license     display software license
  -n, --no-name     do not save or restore the original name and time stamp
  -N, --name        save or restore the original name and time stamp
  -q, --quiet       suppress all warnings
  -r, --recursive   operate recursively on directories
  -S, --suffix=SUF  use suffix SUF on compressed files
  -t, --test        test compressed file integrity
  -v, --verbose     verbose mode
  -V, --version     display version number
  -1, --fast        compress faster
  -9, --best        compress better
    --rsyncable   Make rsync-friendly archive

With no FILE, or when FILE is -, read standard input.

Report bugs to <[email protected]>.
root@web [~]#

したがって、.gzアーカイブを抽出するには、 gzipを使用します。 ツール:

root@web [/]# gzip -d archive_file.gz

またはgunzip

root@web [/]# gunzip archive_file.gz

しかし、どのようにファイルを圧縮しますか?次の表で、ファイル/ディレクトリを圧縮するためのいくつかのコマンドを参照してください。

圧縮コマンド 情報
gzip file1.htm gzipを使用してファイルを圧縮します。
bzip2 file1.htm bzip2を使用してファイルを圧縮します。
zip file1.zip file1.htm file1.htmをアーカイブfile1.zipに圧縮します。
tar -zcvf files1.tgz file.htm
tar -zcvf files1.tgz * .htm
tar -zcvf files1.tgz / directory / dir1 /
tar -jcvf files1.tbz2 file.htm
tar -jcvf files1.tbz2 * .htm
tar -jcvf files1.tbz2 / directory / dir1 /
tarユーティリティを使用すると、多くのファイルを圧縮できます。
-gzip圧縮の場合はz; -bzip2圧縮の場合はj

たとえば、ディレクトリ全体(すべてのサブディレクトリを含む)を圧縮するには、次を使用します。

root@web [/]# tar -czvf archive.tar.gz /home/temp2/

もう1つの一般的なアーカイブタイプはRARです 。 RARプログラムはhttp://rarlabs.com/download.htmからダウンロードできます(Linux 32/64の場合、コマンドラインバージョンのみが使用可能です)。
インストール方法:

root@web [/temp2]# wget http://rarlabs.com/rar/rarlinux-x64-5.5.b3.tar.gz
--2017-05-26 14:54:47--  http://rarlabs.com/rar/rarlinux-x64-5.5.b3.tar.gz
Resolving rarlabs.com (rarlabs.com)... 5.135.104.98
Connecting to rarlabs.com (rarlabs.com)|5.135.104.98|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 534195 (522K) [application/x-gzip]
Saving to: 'rarlinux-x64-5.5.b3.tar.gz'

100%[========================================================================================================

2017-05-26 14:54:48 (845 KB/s) - 'rarlinux-x64-5.5.b3.tar.gz' saved [534195/534195]
root@web [/temp2]# tar -zxvf rarlinux-x64-5.5.b3.tar.gz
rar/
rar/order.htm
rar/acknow.txt
rar/readme.txt
rar/default.sfx
rar/license.txt
rar/rarfiles.lst
rar/whatsnew.txt
rar/makefile
rar/rar
rar/unrar
rar/rar.txt
root@web [/temp2]# cd rar
root@web [/temp2/rar]# install rar unrar
root@web [/temp2/rar]# rar -?

RAR 5.50 beta 3   Copyright (c) 1993-2017 Alexander Roshal   23 May 2017
Trial version             Type 'rar -?' for help

Usage:     rar <command></command> - -  
               <@listfiles...> <path_to_extract\>

  a             Add files to archive
  c             Add archive comment
  ch            Change archive parameters
  cw            Write archive comment to file
  d             Delete files from archive
  e             Extract files without archived paths
  f             Freshen files in archive
  i[par]=  Find string in archives
  k             Lock archive
  l[t[a],b]     List archive contents [technical[all], bare]
  m[f]          Move to archive [files only]
  p             Print file to stdout
  r             Repair archive
  rc            Reconstruct missing volumes
  rn            Rename archived files
  rr[N]         Add data recovery record
  rv[N]         Create recovery volumes
  s[name|-]     Convert archive to or from SFX
  t             Test archive files
  u             Update files in archive
  v[t[a],b]     Verbosely list archive contents [technical[all],bare]
  x             Extract files with full path
....

Linux
  1. Linuxでファイルを圧縮および解凍する方法

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

  3. Linux で tar コマンドを使用する方法

  1. LinuxでTarコマンドを使用する方法

  2. Linuxでtar.xzファイルを抽出または解凍する方法

  3. bzip2 コマンドを使用して Linux で .bz2 ファイルを圧縮および解凍する方法

  1. Linuxでファイルを移動する方法

  2. Linuxでファイルの名前を変更するにはどうすればよいですか?

  3. すべての Linux 圧縮/解凍コマンド