Tar 由 'Tape archiver(磁帶歸檔器)' 衍生而來,最初被用來在磁帶上歸檔和存儲文件。Tar 是一個 GNU 軟件,它可以壓縮一組文件(歸檔),或提取它們以及對已有的歸檔文件進行相關(guān)操作。在存儲、備份以及傳輸文件方面,它是很有用的。在創(chuàng)建歸檔文件時,Tar 可以保持原有文件和目錄結(jié)構(gòu)不變。通過 Tar 歸檔的文件的后綴名為 ‘.tar’。
基本用法如下:
a) 創(chuàng)建歸檔 (c / --create)
tar --create --verbose --file=archive.tar file1 file2 file3
或
tar cvf archive.tar file1 file2 file3
創(chuàng)建一個歸檔
b) 列出歸檔文件內(nèi)容 ( t / --list)
tar --list archive.tar
列出歸檔中包含的文件
c) 提取歸檔 (x / --extract)
tar xvf archive.tar
tar xvf archive.tar --wildcards '*.c'
- 從歸檔中提取后綴名為 *.c 的文件。
提取文件

只提取需要的文件
d) 對歸檔文件進行更新 ( u / --update)
tar uvf archive.tar newfile.c
- 假如歸檔的newfile.c 要比先前已經(jīng)歸檔的新,則添加更新的 newfile.c 到歸檔里面.
更新一個歸檔
e) 從歸檔中刪除文件 (--delete)
tar --delete -f archive.tar file1.c
- 從壓縮包'archive.tar' 中刪除文件'file1.c'
刪除文件
更加具體的使用方法請參考tar 主頁。