1、命令名稱:gzip
執行許可權:所有使用者
功能描述:壓縮檔
文法:gzip 選項 [檔案]
壓縮後格式:.gz
gzip只能壓縮檔,不能壓縮目錄;
gzip壓縮後不保留原檔案
[root@localhost abc]# lsafile issue.hard issue.soft prem test[root@localhost abc]# gzip afile[root@localhost abc]# lsafile.gz issue.hard issue.soft prem test[root@localhost abc]#
2、命令名稱:gunzip
執行許可權:所有使用者
功能描述:解壓.gz格式的壓縮檔
文法:gunzip 選項 [壓縮檔]
[root@localhost abc]# gunzip afile.gz[root@localhost abc]# lsafile issue.hard issue.soft prem test[root@localhost abc]#
或者使用: gzip -d 壓縮檔
[root@localhost abc]# lsafile.gz issue.hard issue.soft prem test[root@localhost abc]# gzip -d afile.gz[root@localhost abc]# lsafile issue.hard issue.soft prem test[root@localhost abc]#
3、命令名稱:tar
執行許可權:所有使用者
功能描述:打包目錄
文法:tar [cvf] [目錄]
-c 產生.tar打包檔案
-v 顯示詳細資料
-f 指定壓縮後的檔案名稱
-z 打包同時壓縮
打包壓縮後格式:.tar.gz
將test目錄打包並壓縮[root@localhost abc]# tar -zcvf test.tar.gz testtest/[root@localhost abc]# lsafile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# 將adir目錄先打包,再壓縮[root@localhost abc]# tar -cvf adir.tar adiradir/[root@localhost abc]# lsadir adir.tar afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# gzip adir.tar[root@localhost abc]# lsadir adir.tar.gz afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]#
使用tar命令解壓縮:
-x 解包.tar檔案
-v 顯示詳細資料
-f 指定解壓檔案
-z 解壓縮
解壓縮test.tar.gz[root@localhost abc]# lsadir.tar.gz afile issue.hard issue.soft prem test.tar.gz[root@localhost abc]# tar -zxvf test.tar.gztest/[root@localhost abc]# lsadir.tar.gz afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# 先解壓,再解包adir.tar.gz[root@localhost abc]# lsadir.tar.gz afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# gunzip adir.tar.gz[root@localhost abc]# lsadir.tar afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# tar -xvf adir.tar
4、命令名稱:zip
執行許可權:所有使用者
功能描述:壓縮檔或目錄
文法:zip [-r] [壓縮後檔案名稱] [檔案或目錄]
-r 壓縮目錄
壓縮後格式:.zip
壓縮afile檔案[root@localhost abc]# lsadir adir.tar afile issue.hard issue.soft prem test test.tar.gz[root@localhost abc]# zip afile.zip afile adding: afile (stored 0%)[root@localhost abc]# lsadir afile issue.hard prem test.tar.gzadir.tar afile.zip issue.soft test[root@localhost abc]# 壓縮test目錄[root@localhost abc]# lsadir afile issue.hard prem test.tar.gzadir.tar afile.zip issue.soft test[root@localhost abc]# zip -r test.zip test adding: test/ (stored 0%)[root@localhost abc]# lsadir afile issue.hard prem test.tar.gzadir.tar afile.zip issue.soft test test.zip[root@localhost abc]#
5、命令名稱:unzip
執行許可權:所有使用者
功能描述:解壓.zip格式的壓縮檔
文法:unzip [壓縮檔]
解壓test.zip[root@localhost abc]# unzip test.zipArchive: test.zip creating: test/[root@localhost abc]#
6、命令名稱:bzip2
執行許可權:所有使用者
功能描述:壓縮檔
文法:bzip2 [-k] [檔案]
-k 產生壓縮檔後保留原檔案
壓縮後格式:.bz2
只能壓縮檔
壓縮比很大,適合壓縮很大的檔案
壓縮afile[root@localhost abc]# bzip2 -k afile[root@localhost abc]# lsadir afile afile.zip issue.soft test test.zipadir.tar afile.bz2 issue.hard prem test.tar.gz[root@localhost abc]#
7、命令名稱:bunzip2
執行許可權:所有使用者
功能描述:解壓檔案
文法:bunzip2 [-k] [壓縮檔]
-k 解壓後保留原檔案
解壓afile.bz2[root@localhost abc]# bunzip2 -k afile.bz2
8、查看檔案類型命令 file
如果不知道檔案的類型,可以使用:file 檔案
[root@localhost abc]# file /etc/sysconfig/etc/sysconfig: directory[root@localhost abc]#