Linux 下 7z 的使用方式

CentOS 7.x 安裝
# yum install epel-release
# yum update
# yum install p7zip

Arch Linux 安裝
# pacman -S p7zip

Ubuntu / Debian
# apt-get install p7zip-full 

# apt-get install p7zip[@more@]CentOS 可用指令 7za
Arch Linux / Debian / Ubuntu 可用指令 7z / 7za

常用參數
壓縮
# 7z a 壓縮檔名.7z 要壓縮的檔案或目錄1 要壓縮的檔案或目錄2

解壓縮
# 7z x 壓縮檔名.7z

# 7z e 壓縮檔名.7z

xe 差別,如果建立壓縮檔時有包含目錄,則 x 會依照原本壓縮時的樣子來還原,e 會建立原來的空目錄名稱,並把檔案解開在目錄名稱的外面
原則上會建議使用 x

列出壓縮檔的內容
# 7z l 壓縮檔名.7z

解壓縮時指定目錄
# 7z x 壓縮檔名.7z -o目錄位置
# 7z x 123.7z -o/tmp

更多的參數
# 7z –help

<Commands>
  a : Add files to archive
  b : Benchmark
  d : Delete files from archive
  e : Extract files from archive (without using directory names)
  h : Calculate hash values for files
  i : Show information about supported formats
  l : List contents of archive
  rn : Rename files in archive
  t : Test integrity of archive
  u : Update files to archive
  x : eXtract files with full paths