一,歸檔及壓縮的作用
作用:1.減小占用的硬碟空間 2.整合分散的檔案
二、tar命令的選項
– -c:創建歸檔
– -x:釋放歸檔
– -f:指定歸檔檔案名稱,必須放在所有選項的最后
– -z、-j、-J:呼叫 .gz、.bz2、.xz 格式的工具進行處理
– -t:顯示歸檔中的檔案清單
– -C:指定釋放路徑
三、使用步驟
1.tar 制作壓縮包(打包)
格式:tar 選項 /路徑/壓縮包的名字 /路徑/源資料…….
代碼如下:
[root@WXR ~]# tar -zcf /opt/abc.tar.gz /home/ /etc/passwd
[root@WXR ~]# tar -jcf /opt/test.tar.bz2 /home/ /etc/passwd
[root@WXR ~]# tar -Jcf /opt/nsd.tar.xz /home/ /etc/passwd
[root@WXR ~]# ls /opt/
abc.tar.gz nsd.tar.xz rh test.tar.bz2
2.tar 釋放壓縮包(解包)
格式:tar 選項 /路徑/tar包 -C(大寫) /路徑/目標位置
-x:釋放 -f:指定壓縮包名稱
代碼如下:
[root@WXR ~]# tar -xf /opt/abc.tar.gz -C /wxr
[root@WXR ~]# ls /wxr/
etc home
3.查看tar包內容
[root@WXR ~]# tar -tf /opt/abc.tar.gz
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/13355.html
標籤:其他
