tar
-c: 建立壓縮檔案
-x:解壓
-t:檢視内容
-r:向壓縮歸檔檔案末尾追加檔案
-u:更新原壓縮包中的檔案
這五個是獨立的指令,壓縮解壓都要用到其中一個,可以和别的指令連用但隻能用其中一個。下面的參數是根據需要在壓縮或解壓檔案時可選的。
-z:有gzip屬性的
-j:有bz2屬性的
-Z:有compress屬性的
-v:顯示所有過程
-O:将檔案解開到标準輸出
下面的參數-f是必須的
-f: 使用檔案名字,切記,這個參數是最後一個參數,後面隻能接檔案名。
# tar -cf all.tar *.jpg
這條指令是将所有.jpg的檔案打成一個名為all.tar的包。-c是表示産生新的包,-f指定包的檔案名。
# tar -rf all.tar *.gif
這條指令是将所有.gif的檔案增加到all.tar的包裡面去。-r是表示增加檔案的意思。
# tar -uf all.tar logo.gif
這條指令是更新原來tar包all.tar中logo.gif檔案,-u是表示更新檔案的意思。
# tar -tf all.tar
這條指令是列出all.tar包中所有檔案,-t是列出檔案的意思
# tar -xf all.tar
這條指令是解出all.tar包中所有檔案,-t是解開的意思
壓縮
tar -cvf jpg.tar *.jpg //将目錄裡所有jpg檔案打包成tar.jpg
tar -czf jpg.tar.gz *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用gzip壓縮,生成一個gzip壓縮過的包,命名為jpg.tar.gz
tar -cjf jpg.tar.bz2 *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用bzip2壓縮,生成一個bzip2壓縮過的包,命名為jpg.tar.bz2
tar -cZf jpg.tar.Z *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用compress壓縮,生成一個umcompress壓縮過的包,命名為jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的壓縮,需要先下載下傳rar for linux
zip jpg.zip *.jpg //zip格式的壓縮,需要先下載下傳zip for linux
解壓
tar -xvf file.tar //解壓 tar包
tar -xzvf file.tar.gz //解壓tar.gz
tar -xjvf file.tar.bz2 //解壓 tar.bz2
tar -xZvf file.tar.Z //解壓tar.Z
unrar e file.rar //解壓rar
unzip file.zip //解壓zip
總結
1、*.tar 用 tar -xvf 解壓
2、*.gz 用 gzip -d或者gunzip 解壓
3、*.tar.gz和*.tgz 用 tar -xzf 解壓
4、*.bz2 用 bzip2 -d或者用bunzip2 解壓
5、*.tar.bz2用tar -xjf 解壓
6、*.Z 用 uncompress 解壓
7、*.tar.Z 用tar -xZf 解壓
8、*.rar 用 unrar e解壓
9、*.zip 用 unzip 解壓
解壓jdk到指定檔案夾:
tar -xzvf jdk-8u131-linux-x64.tar.gz -C /usr/local/java
- root @ubuntu:~# tar --help
- 用法: tar [選項...] [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.
- 主操作模式:
- -A, --catenate, --concatenate 追加 tar 檔案至歸檔
- -c, --create 建立一個新歸檔
- -d, --diff, --compare 找出歸檔和檔案系統的差異
- --delete 從歸檔(非錄音帶!)中删除
- -r, --append 追加檔案至歸檔結尾
- -t, --list 列出歸檔内容
- --test-label 測試歸檔卷标并退出
- -u, --update 僅追加比歸檔中副本更新的檔案
- -x, --extract, --get 從歸檔中解出檔案
- 操作修飾符:
- --check-device 當建立增量歸檔時檢查裝置号(預設)
- -g, --listed-incremental=FILE 處理新式的 GNU 格式的增量備份
- -G, --incremental 處理老式的 GNU 格式的增量備份
- --ignore-failed-read
- 當遇上不可讀檔案時不要以非零值退出
- --level=NUMBER 所建立的增量清單歸檔的輸出級别
- -n, --seek 歸檔可檢索
- --no-check-device 當建立增量歸檔時不要檢查裝置号
- --no-seek 歸檔不可檢索
- --occurrence[=NUMBER] 僅處理歸檔中每個檔案的第 NUMBER
- 個事件;僅當與以下子指令 --delete,
- --diff, --extract 或是 --list
- 中的一個聯合使用時,此選項才有效。而且不管檔案清單是以指令行形式給出或是通過
- -T 選項指定的;NUMBER 值預設為
- --sparse-version=MAJOR[.MINOR]
- 設定所用的離散格式版本(隐含
- --sparse)
- -S, --sparse 高效處理離散檔案
- 重寫控制:
- -k, --keep-old-files don 't replace existing files when extracting,
- treat them as errors
- --keep-directory-symlink preserve existing symlinks to directories when
- extracting
- --keep-newer-files
- 不要替換比歸檔中副本更新的已存在的檔案
- --no-overwrite-dir 保留已存在目錄的中繼資料
- --one-top-level[=DIR] create a subdirectory to avoid having loose files
- extracted
- --overwrite 解壓時重寫存在的檔案
- --overwrite-dir 解壓時重寫已存在目錄的中繼資料(預設)
- --recursive-unlink 解壓目錄之前先清除目錄層次
- --remove-files 在添加檔案至歸檔後删除它們
- --skip-old-files don't replace existing files when extracting,
- silently skip over them
- -U, --unlink-first 在解壓要重寫的檔案之前先删除它們
- -W, --verify 在寫入以後嘗試校驗歸檔
- 選擇輸出流:
- --ignore-command-error 忽略子程序的退出代碼
- --no-ignore-command-error
- 将子程序的非零退出代碼認為發生錯誤
- -O, --to-stdout 解壓檔案至标準輸出
- --to-command=COMMAND
- 将解壓的檔案通過管道傳送至另一個程式
- 操作檔案屬性:
- --atime-preserve[=METHOD]
- 在輸出的檔案上保留通路時間,要麼通過在讀取(預設
- METHOD=‘replace’)後還原時間,要不就不要在第一次(METHOD=‘system’)設定時間
- --clamp-mtime only set time when the file is more recent than
- what was given with --mtime
- --delay-directory-restore
- 直到解壓結束才設定修改時間和所解目錄的權限
- --group=名稱 強制将 NAME
- 作為所添加的檔案的組所有者
- --mode=CHANGES 強制将所添加的檔案(符号)更改為權限
- CHANGES
- --mtime=DATE-OR-FILE 從 DATE-OR-FILE 中為添加的檔案設定
- mtime
- -m, --touch 不要解壓檔案的修改時間
- --no-delay-directory-restore
- 取消 --delay-directory-restore 選項的效果
- --no-same-owner
- 将檔案解壓為您所有(普通使用者預設此項)
- --no-same-permissions
- 從歸檔中解壓權限時使用使用者的掩碼位(預設為普通使用者服務)
- --numeric-owner 總是以數字代表使用者/組的名稱
- --owner=名稱 強制将 NAME
- 作為所添加的檔案的所有者
- -p, --preserve-permissions, --same-permissions
- 解壓檔案權限資訊(預設隻為超級使用者服務)
- --preserve 與 -p 和 -s 一樣
- --same-owner
- 嘗試解壓時保持所有者關系一緻(超級使用者預設此項)
- -s, --preserve-order, --same-order
- member arguments are listed in the same order as
- the files in the archive
- --sort=ORDER directory sorting order: none ( default), name or
- inode
- Handling of extended file attributes:
- --acls Enable the POSIX ACLs support
- --no-acls Disable the POSIX ACLs support
- --no-selinux Disable the SELinux context support
- --no-xattrs Disable extended attributes support
- --selinux Enable the SELinux context support
- --xattrs Enable extended attributes support
- --xattrs-exclude=MASK specify the exclude pattern for xattr keys
- --xattrs-include=MASK specify the include pattern for xattr keys
- 裝置選擇和切換:
- -f, --file=ARCHIVE 使用歸檔檔案或 ARCHIVE 裝置
- --force-local
- 即使歸檔檔案存在副本還是把它認為是本地歸檔
- -F, --info-script=名稱, -- new-volume-script=名稱
- 在每卷錄音帶最後運作腳本(隐含 -M)
- -L, --tape-length=NUMBER 寫入 NUMBER × 位元組後更換錄音帶
- -M, --multi-volume 建立/列出/解壓多卷歸檔檔案
- --rmt-command=COMMAND 使用指定的 rmt COMMAND 代替 rmt
- --rsh-command=COMMAND 使用遠端 COMMAND 代替 rsh
- --volno-file=FILE 使用/更新 FILE 中的卷數
- 裝置分塊:
- -b, --blocking-factor=BLOCKS 每個記錄 BLOCKS x 位元組
- -B, --read-full-records 讀取時重新分塊(隻對 BSD 管道有效)
- -i, --ignore-zeros 忽略歸檔中的零位元組塊(即檔案結尾)
- --record-size=NUMBER 每個記錄的位元組數 NUMBER,乘以
- 選擇歸檔格式:
- -H, --format=FORMAT 建立指定格式的歸檔
- FORMAT 是以下格式中的一種:
- gnu GNU tar .x 格式
- oldgnu GNU 格式 as per tar <=
- pax POSIX - (pax) 格式
- posix 等同于 pax
- ustar POSIX - (ustar) 格式
- v7 old V7 tar 格式
- --old-archive, --portability
- 等同于 --format=v7
- --pax-option=關鍵字[[:]=值][,關鍵字[[:]=值]]...
- 控制 pax 關鍵字
- --posix 等同于 --format=posix
- -V, --label=TEXT 建立帶有卷名 TEXT
- 的歸檔;在列出/解壓時,使用 TEXT
- 作為卷名的模式串
- 壓縮選項:
- -a, --auto-compress 使用歸檔字尾名來決定壓縮程式
- -I, --use-compress-program=PROG
- 通過 PROG 過濾(必須是能接受 -d
- 選項的程式)
- -j, --bzip2 通過 bzip2 過濾歸檔
- -J, --xz 通過 xz 過濾歸檔
- --lzip 通過 lzip 過濾歸檔
- --lzma 通過 xz 過濾歸檔
- --lzop 通過 xz 過濾歸檔
- --no-auto-compress 不使用歸檔字尾名來決定壓縮程式
- -z, --gzip, --gunzip, --ungzip 通過 gzip 過濾歸檔
- -Z, --compress, --uncompress 通過 compress 過濾歸檔
- 本地檔案選擇:
- --add-file=FILE 添加指定的 FILE 至歸檔(如果名字以 -
- 開始會很有用的)
- --backup[=CONTROL] 在删除前備份,選擇 CONTROL 版本
- -C, --directory=DIR 改變至目錄 DIR
- --exclude=PATTERN 排除以 PATTERN 指定的檔案
- --exclude-backups 排除備份和鎖檔案
- --exclude-caches 除辨別檔案本身外,排除包含
- CACHEDIR.TAG 的目錄中的内容
- --exclude-caches-all 排除包含 CACHEDIR.TAG 的目錄
- --exclude-caches-under 排除包含 CACHEDIR.TAG
- 的目錄中所有内容
- --exclude-ignore=FILE read exclude patterns for each directory from
- FILE, if it exists
- --exclude-ignore-recursive=FILE
- read exclude patterns for each directory and its
- subdirectories from FILE, if it exists
- --exclude-tag=FILE 除 FILE 自身外,排除包含 FILE
- 的目錄中的内容
- --exclude-tag-all=FILE 排除包含 FILE 的目錄
- --exclude-tag-under=FILE 排除包含 FILE 的目錄中的所有内容
- --exclude-vcs 排除版本控制系統目錄
- --exclude-vcs-ignores read exclude patterns from the VCS ignore files
- -h, --dereference
- 跟蹤符号連結;将它們所指向的檔案歸檔并輸出
- --hard-dereference
- 跟蹤硬連結;将它們所指向的檔案歸檔并輸出
- -K, --starting-file=MEMBER-NAME
- begin at member MEMBER-NAME when reading the
- archive
- --newer-mtime=DATE 當隻有資料改變時比較資料和時間
- --no- null 禁用上一次的效果 -- null 選項
- --no-recursion 避免目錄中的自動降級
- --no-unquote do not unquote input file or member names
- -- null -T 讀取以空終止的名字,-C 禁用
- -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
- 隻儲存比 DATE-OR-FILE 更新的檔案
- --one-file-system 建立歸檔時儲存在本地檔案系統中
- -P, --absolute-names don 't strip leading '/ 's from file names
- --recursion 目錄遞歸(預設)
- --suffix=STRING 在删除前備份,除非被環境變量
- SIMPLE_BACKUP_SUFFIX
- 覆寫,否則覆寫常用字尾(‘’)
- -T, --files-from=FILE 從 FILE
- 中擷取檔案名來解壓或建立檔案
- --unquote unquote input file or member names (default)
- -X, --exclude-from=FILE 排除 FILE 中列出的模式串
- 檔案名變換:
- --strip-components=NUMBER 解壓時從檔案名中清除 NUMBER
- 個引導部分
- --transform=EXPRESSION, --xform=EXPRESSION
- 使用 sed 代替 EXPRESSION
- 來進行檔案名變換
- 檔案名比對選項(同時影響排除和包括模式串):
- --anchored 模式串比對檔案名頭部
- --ignore-case 忽略大小寫
- --no-anchored patterns match after any '/ ' (default for
- exclusion)
- --no-ignore-case 比對大小寫(預設)
- --no-wildcards 逐字比對字元串
- --no-wildcards-match-slash wildcards do not match '/ '
- --wildcards 使用通配符(預設對 exclusion )
- --wildcards-match-slash wildcards match '/ ' (default for exclusion)
- 提示性輸出:
- --checkpoint[=NUMBER] 每隔 NUMBER
- 個記錄顯示進度資訊(預設為 10 個)
- --checkpoint-action=ACTION 在每個檢查點上執行 ACTION
- --full-time 按檔案原本時間格式列印
- --index-file=FILE 将詳細輸出發送至 FILE
- -l, --check-links
- 隻要不是所有連結都被輸出就列印資訊
- --no-quote-chars=STRING 禁用來自 STRING 的字元引用
- --quote-chars=STRING 來自 STRING 的額外的引用字元
- --quoting-style=STYLE 設定名稱引用風格;有效的 STYLE
- 值請參閱以下說明
- -R, --block-number 每個資訊都顯示歸檔内的塊數
- --show-defaults 顯示 tar 預設選項
- --show-omitted-dirs
- 清單或解壓時,列出每個不比對查找标準的目錄
- --show-snapshot-field-ranges
- show valid ranges for snapshot-file fields
- --show-transformed-names, --show-stored-names
- 顯示變換後的檔案名或歸檔名
- --totals[=SIGNAL] 處理歸檔後列印出總位元組數;當此
- SIGNAL 被觸發時帶參數 -
- 列印總位元組數;允許的信号為:
- SIGHUP,SIGQUIT,SIGINT,SIGUSR1 和
- SIGUSR2;同時也接受不帶 SIG
- 字首的信号名稱
- --utc 以 UTC 格式列印檔案修改時間
- -v, --verbose 詳細地列出處理的檔案
- --warning=KEYWORD 警告控制:
- -w, --interactive, --confirmation
- 每次操作都要求确認
- 相容性選項:
- -o 建立歸檔時,相當于
- --old-archive;展開歸檔時,相當于
- --no-same-owner
- 其它選項:
- -?, --help 顯示此幫助清單
- --restrict 禁用某些潛在的有危險的選項
- --usage 顯示簡短的用法說明
- --version 列印程式版本
- 長選項和相應短選項具有相同的強制參數或可選參數。
- The backup suffix is '~ ', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
- The version control may be set with --backup or VERSION_CONTROL, values are:
- none, off never make backups
- t, numbered make numbered backups
- nil, existing numbered if numbered backups exist, simple otherwise
- never, simple always make simple backups
- --quoting-style 選項的有效參數為:
- literal
- shell
- shell-always
- c
- c-maybe
- escape
- locale
- clocale
- 此 tar 預設為:
- --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt
- --rsh-command=/usr/bin/rsh
- 将錯誤報告發送到 <[email protected]>。
tar
-c: 建立壓縮檔案
-x:解壓
-t:檢視内容
-r:向壓縮歸檔檔案末尾追加檔案
-u:更新原壓縮包中的檔案
這五個是獨立的指令,壓縮解壓都要用到其中一個,可以和别的指令連用但隻能用其中一個。下面的參數是根據需要在壓縮或解壓檔案時可選的。
-z:有gzip屬性的
-j:有bz2屬性的
-Z:有compress屬性的
-v:顯示所有過程
-O:将檔案解開到标準輸出
下面的參數-f是必須的
-f: 使用檔案名字,切記,這個參數是最後一個參數,後面隻能接檔案名。
# tar -cf all.tar *.jpg
這條指令是将所有.jpg的檔案打成一個名為all.tar的包。-c是表示産生新的包,-f指定包的檔案名。
# tar -rf all.tar *.gif
這條指令是将所有.gif的檔案增加到all.tar的包裡面去。-r是表示增加檔案的意思。
# tar -uf all.tar logo.gif
這條指令是更新原來tar包all.tar中logo.gif檔案,-u是表示更新檔案的意思。
# tar -tf all.tar
這條指令是列出all.tar包中所有檔案,-t是列出檔案的意思
# tar -xf all.tar
這條指令是解出all.tar包中所有檔案,-t是解開的意思
壓縮
tar -cvf jpg.tar *.jpg //将目錄裡所有jpg檔案打包成tar.jpg
tar -czf jpg.tar.gz *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用gzip壓縮,生成一個gzip壓縮過的包,命名為jpg.tar.gz
tar -cjf jpg.tar.bz2 *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用bzip2壓縮,生成一個bzip2壓縮過的包,命名為jpg.tar.bz2
tar -cZf jpg.tar.Z *.jpg //将目錄裡所有jpg檔案打包成jpg.tar後,并且将其用compress壓縮,生成一個umcompress壓縮過的包,命名為jpg.tar.Z
rar a jpg.rar *.jpg //rar格式的壓縮,需要先下載下傳rar for linux
zip jpg.zip *.jpg //zip格式的壓縮,需要先下載下傳zip for linux
解壓
tar -xvf file.tar //解壓 tar包
tar -xzvf file.tar.gz //解壓tar.gz
tar -xjvf file.tar.bz2 //解壓 tar.bz2
tar -xZvf file.tar.Z //解壓tar.Z
unrar e file.rar //解壓rar
unzip file.zip //解壓zip
總結
1、*.tar 用 tar -xvf 解壓
2、*.gz 用 gzip -d或者gunzip 解壓
3、*.tar.gz和*.tgz 用 tar -xzf 解壓
4、*.bz2 用 bzip2 -d或者用bunzip2 解壓
5、*.tar.bz2用tar -xjf 解壓
6、*.Z 用 uncompress 解壓
7、*.tar.Z 用tar -xZf 解壓
8、*.rar 用 unrar e解壓
9、*.zip 用 unzip 解壓
解壓jdk到指定檔案夾:
tar -xzvf jdk-8u131-linux-x64.tar.gz -C /usr/local/java
- root @ubuntu:~# tar --help
- 用法: tar [選項...] [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.
- 主操作模式:
- -A, --catenate, --concatenate 追加 tar 檔案至歸檔
- -c, --create 建立一個新歸檔
- -d, --diff, --compare 找出歸檔和檔案系統的差異
- --delete 從歸檔(非錄音帶!)中删除
- -r, --append 追加檔案至歸檔結尾
- -t, --list 列出歸檔内容
- --test-label 測試歸檔卷标并退出
- -u, --update 僅追加比歸檔中副本更新的檔案
- -x, --extract, --get 從歸檔中解出檔案
- 操作修飾符:
- --check-device 當建立增量歸檔時檢查裝置号(預設)
- -g, --listed-incremental=FILE 處理新式的 GNU 格式的增量備份
- -G, --incremental 處理老式的 GNU 格式的增量備份
- --ignore-failed-read
- 當遇上不可讀檔案時不要以非零值退出
- --level=NUMBER 所建立的增量清單歸檔的輸出級别
- -n, --seek 歸檔可檢索
- --no-check-device 當建立增量歸檔時不要檢查裝置号
- --no-seek 歸檔不可檢索
- --occurrence[=NUMBER] 僅處理歸檔中每個檔案的第 NUMBER
- 個事件;僅當與以下子指令 --delete,
- --diff, --extract 或是 --list
- 中的一個聯合使用時,此選項才有效。而且不管檔案清單是以指令行形式給出或是通過
- -T 選項指定的;NUMBER 值預設為
- --sparse-version=MAJOR[.MINOR]
- 設定所用的離散格式版本(隐含
- --sparse)
- -S, --sparse 高效處理離散檔案
- 重寫控制:
- -k, --keep-old-files don 't replace existing files when extracting,
- treat them as errors
- --keep-directory-symlink preserve existing symlinks to directories when
- extracting
- --keep-newer-files
- 不要替換比歸檔中副本更新的已存在的檔案
- --no-overwrite-dir 保留已存在目錄的中繼資料
- --one-top-level[=DIR] create a subdirectory to avoid having loose files
- extracted
- --overwrite 解壓時重寫存在的檔案
- --overwrite-dir 解壓時重寫已存在目錄的中繼資料(預設)
- --recursive-unlink 解壓目錄之前先清除目錄層次
- --remove-files 在添加檔案至歸檔後删除它們
- --skip-old-files don't replace existing files when extracting,
- silently skip over them
- -U, --unlink-first 在解壓要重寫的檔案之前先删除它們
- -W, --verify 在寫入以後嘗試校驗歸檔
- 選擇輸出流:
- --ignore-command-error 忽略子程序的退出代碼
- --no-ignore-command-error
- 将子程序的非零退出代碼認為發生錯誤
- -O, --to-stdout 解壓檔案至标準輸出
- --to-command=COMMAND
- 将解壓的檔案通過管道傳送至另一個程式
- 操作檔案屬性:
- --atime-preserve[=METHOD]
- 在輸出的檔案上保留通路時間,要麼通過在讀取(預設
- METHOD=‘replace’)後還原時間,要不就不要在第一次(METHOD=‘system’)設定時間
- --clamp-mtime only set time when the file is more recent than
- what was given with --mtime
- --delay-directory-restore
- 直到解壓結束才設定修改時間和所解目錄的權限
- --group=名稱 強制将 NAME
- 作為所添加的檔案的組所有者
- --mode=CHANGES 強制将所添加的檔案(符号)更改為權限
- CHANGES
- --mtime=DATE-OR-FILE 從 DATE-OR-FILE 中為添加的檔案設定
- mtime
- -m, --touch 不要解壓檔案的修改時間
- --no-delay-directory-restore
- 取消 --delay-directory-restore 選項的效果
- --no-same-owner
- 将檔案解壓為您所有(普通使用者預設此項)
- --no-same-permissions
- 從歸檔中解壓權限時使用使用者的掩碼位(預設為普通使用者服務)
- --numeric-owner 總是以數字代表使用者/組的名稱
- --owner=名稱 強制将 NAME
- 作為所添加的檔案的所有者
- -p, --preserve-permissions, --same-permissions
- 解壓檔案權限資訊(預設隻為超級使用者服務)
- --preserve 與 -p 和 -s 一樣
- --same-owner
- 嘗試解壓時保持所有者關系一緻(超級使用者預設此項)
- -s, --preserve-order, --same-order
- member arguments are listed in the same order as
- the files in the archive
- --sort=ORDER directory sorting order: none ( default), name or
- inode
- Handling of extended file attributes:
- --acls Enable the POSIX ACLs support
- --no-acls Disable the POSIX ACLs support
- --no-selinux Disable the SELinux context support
- --no-xattrs Disable extended attributes support
- --selinux Enable the SELinux context support
- --xattrs Enable extended attributes support
- --xattrs-exclude=MASK specify the exclude pattern for xattr keys
- --xattrs-include=MASK specify the include pattern for xattr keys
- 裝置選擇和切換:
- -f, --file=ARCHIVE 使用歸檔檔案或 ARCHIVE 裝置
- --force-local
- 即使歸檔檔案存在副本還是把它認為是本地歸檔
- -F, --info-script=名稱, -- new-volume-script=名稱
- 在每卷錄音帶最後運作腳本(隐含 -M)
- -L, --tape-length=NUMBER 寫入 NUMBER × 位元組後更換錄音帶
- -M, --multi-volume 建立/列出/解壓多卷歸檔檔案
- --rmt-command=COMMAND 使用指定的 rmt COMMAND 代替 rmt
- --rsh-command=COMMAND 使用遠端 COMMAND 代替 rsh
- --volno-file=FILE 使用/更新 FILE 中的卷數
- 裝置分塊:
- -b, --blocking-factor=BLOCKS 每個記錄 BLOCKS x 位元組
- -B, --read-full-records 讀取時重新分塊(隻對 BSD 管道有效)
- -i, --ignore-zeros 忽略歸檔中的零位元組塊(即檔案結尾)
- --record-size=NUMBER 每個記錄的位元組數 NUMBER,乘以
- 選擇歸檔格式:
- -H, --format=FORMAT 建立指定格式的歸檔
- FORMAT 是以下格式中的一種:
- gnu GNU tar .x 格式
- oldgnu GNU 格式 as per tar <=
- pax POSIX - (pax) 格式
- posix 等同于 pax
- ustar POSIX - (ustar) 格式
- v7 old V7 tar 格式
- --old-archive, --portability
- 等同于 --format=v7
- --pax-option=關鍵字[[:]=值][,關鍵字[[:]=值]]...
- 控制 pax 關鍵字
- --posix 等同于 --format=posix
- -V, --label=TEXT 建立帶有卷名 TEXT
- 的歸檔;在列出/解壓時,使用 TEXT
- 作為卷名的模式串
- 壓縮選項:
- -a, --auto-compress 使用歸檔字尾名來決定壓縮程式
- -I, --use-compress-program=PROG
- 通過 PROG 過濾(必須是能接受 -d
- 選項的程式)
- -j, --bzip2 通過 bzip2 過濾歸檔
- -J, --xz 通過 xz 過濾歸檔
- --lzip 通過 lzip 過濾歸檔
- --lzma 通過 xz 過濾歸檔
- --lzop 通過 xz 過濾歸檔
- --no-auto-compress 不使用歸檔字尾名來決定壓縮程式
- -z, --gzip, --gunzip, --ungzip 通過 gzip 過濾歸檔
- -Z, --compress, --uncompress 通過 compress 過濾歸檔
- 本地檔案選擇:
- --add-file=FILE 添加指定的 FILE 至歸檔(如果名字以 -
- 開始會很有用的)
- --backup[=CONTROL] 在删除前備份,選擇 CONTROL 版本
- -C, --directory=DIR 改變至目錄 DIR
- --exclude=PATTERN 排除以 PATTERN 指定的檔案
- --exclude-backups 排除備份和鎖檔案
- --exclude-caches 除辨別檔案本身外,排除包含
- CACHEDIR.TAG 的目錄中的内容
- --exclude-caches-all 排除包含 CACHEDIR.TAG 的目錄
- --exclude-caches-under 排除包含 CACHEDIR.TAG
- 的目錄中所有内容
- --exclude-ignore=FILE read exclude patterns for each directory from
- FILE, if it exists
- --exclude-ignore-recursive=FILE
- read exclude patterns for each directory and its
- subdirectories from FILE, if it exists
- --exclude-tag=FILE 除 FILE 自身外,排除包含 FILE
- 的目錄中的内容
- --exclude-tag-all=FILE 排除包含 FILE 的目錄
- --exclude-tag-under=FILE 排除包含 FILE 的目錄中的所有内容
- --exclude-vcs 排除版本控制系統目錄
- --exclude-vcs-ignores read exclude patterns from the VCS ignore files
- -h, --dereference
- 跟蹤符号連結;将它們所指向的檔案歸檔并輸出
- --hard-dereference
- 跟蹤硬連結;将它們所指向的檔案歸檔并輸出
- -K, --starting-file=MEMBER-NAME
- begin at member MEMBER-NAME when reading the
- archive
- --newer-mtime=DATE 當隻有資料改變時比較資料和時間
- --no- null 禁用上一次的效果 -- null 選項
- --no-recursion 避免目錄中的自動降級
- --no-unquote do not unquote input file or member names
- -- null -T 讀取以空終止的名字,-C 禁用
- -N, --newer=DATE-OR-FILE, --after-date=DATE-OR-FILE
- 隻儲存比 DATE-OR-FILE 更新的檔案
- --one-file-system 建立歸檔時儲存在本地檔案系統中
- -P, --absolute-names don 't strip leading '/ 's from file names
- --recursion 目錄遞歸(預設)
- --suffix=STRING 在删除前備份,除非被環境變量
- SIMPLE_BACKUP_SUFFIX
- 覆寫,否則覆寫常用字尾(‘’)
- -T, --files-from=FILE 從 FILE
- 中擷取檔案名來解壓或建立檔案
- --unquote unquote input file or member names (default)
- -X, --exclude-from=FILE 排除 FILE 中列出的模式串
- 檔案名變換:
- --strip-components=NUMBER 解壓時從檔案名中清除 NUMBER
- 個引導部分
- --transform=EXPRESSION, --xform=EXPRESSION
- 使用 sed 代替 EXPRESSION
- 來進行檔案名變換
- 檔案名比對選項(同時影響排除和包括模式串):
- --anchored 模式串比對檔案名頭部
- --ignore-case 忽略大小寫
- --no-anchored patterns match after any '/ ' (default for
- exclusion)
- --no-ignore-case 比對大小寫(預設)
- --no-wildcards 逐字比對字元串
- --no-wildcards-match-slash wildcards do not match '/ '
- --wildcards 使用通配符(預設對 exclusion )
- --wildcards-match-slash wildcards match '/ ' (default for exclusion)
- 提示性輸出:
- --checkpoint[=NUMBER] 每隔 NUMBER
- 個記錄顯示進度資訊(預設為 10 個)
- --checkpoint-action=ACTION 在每個檢查點上執行 ACTION
- --full-time 按檔案原本時間格式列印
- --index-file=FILE 将詳細輸出發送至 FILE
- -l, --check-links
- 隻要不是所有連結都被輸出就列印資訊
- --no-quote-chars=STRING 禁用來自 STRING 的字元引用
- --quote-chars=STRING 來自 STRING 的額外的引用字元
- --quoting-style=STYLE 設定名稱引用風格;有效的 STYLE
- 值請參閱以下說明
- -R, --block-number 每個資訊都顯示歸檔内的塊數
- --show-defaults 顯示 tar 預設選項
- --show-omitted-dirs
- 清單或解壓時,列出每個不比對查找标準的目錄
- --show-snapshot-field-ranges
- show valid ranges for snapshot-file fields
- --show-transformed-names, --show-stored-names
- 顯示變換後的檔案名或歸檔名
- --totals[=SIGNAL] 處理歸檔後列印出總位元組數;當此
- SIGNAL 被觸發時帶參數 -
- 列印總位元組數;允許的信号為:
- SIGHUP,SIGQUIT,SIGINT,SIGUSR1 和
- SIGUSR2;同時也接受不帶 SIG
- 字首的信号名稱
- --utc 以 UTC 格式列印檔案修改時間
- -v, --verbose 詳細地列出處理的檔案
- --warning=KEYWORD 警告控制:
- -w, --interactive, --confirmation
- 每次操作都要求确認
- 相容性選項:
- -o 建立歸檔時,相當于
- --old-archive;展開歸檔時,相當于
- --no-same-owner
- 其它選項:
- -?, --help 顯示此幫助清單
- --restrict 禁用某些潛在的有危險的選項
- --usage 顯示簡短的用法說明
- --version 列印程式版本
- 長選項和相應短選項具有相同的強制參數或可選參數。
- The backup suffix is '~ ', unless set with --suffix or SIMPLE_BACKUP_SUFFIX.
- The version control may be set with --backup or VERSION_CONTROL, values are:
- none, off never make backups
- t, numbered make numbered backups
- nil, existing numbered if numbered backups exist, simple otherwise
- never, simple always make simple backups
- --quoting-style 選項的有效參數為:
- literal
- shell
- shell-always
- c
- c-maybe
- escape
- locale
- clocale
- 此 tar 預設為:
- --format=gnu -f- -b20 --quoting-style=escape --rmt-command=/usr/lib/tar/rmt
- --rsh-command=/usr/bin/rsh
- 将錯誤報告發送到 <[email protected]>。