Linux常用命令(5)–壓縮解壓命令

來源:互聯網
上載者:User

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]# 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.