Linux下的压缩与解压命令速查

创建Zip文件。

zip –r myzipfile.zip ./folder_to_zip

解压Zip文件。

unzip myzipfile.zip –d /tmp

--------------


创建Tar文件。

tar -cvf /tmp/mytarfile.tar /tmp/folder_to_be_tarred

解压Tar文件。

tar -xvf mytarfile.tar –C /tmp/folder_to_untar

--------------


创建tar.gz文件。

tar -czvf test123.tar.gz /tmp/folder_to_gz_and_tarred

解压tar.gz文件。

tar -xzvf test123.tar.xz -C ./Extracted/test123

--------------


创建tar.bz2文件

tar -cjvf archive.tar.bz2 /tmp/folder_to_bz2_and_tarred

解压tar.bz2文件。

tar -xjvf archive.tar.bz2 /home/folder_to_untar

--------------


创建tar.xz文件

tar -xvJf files.tar.xz –C ./filestarxz

解压tar.xz文件

tar -xvJf files.tar.xz -C filestarxz

tar -xvf files.tar.xz -C ./filestarxz2



参考资料

=============

https://www.howtogeek.com/248780/how-to-compress-and-extract-files-using-the-tar-command-on-linux/ 

https://www.cyberciti.biz/faq/howto-extract-tar-file-to-specific-directory-on-unixlinux/

https://www.cyberciti.biz/faq/how-to-tar-a-file-in-linux-using-command-line/

https://stackoverflow.com/questions/18855850/create-a-tar-xz-in-one-command

https://www.cyberciti.biz/faq/how-to-create-tar-gz-file-in-linux-using-command-line/

https://www.rootusers.com/13-simple-xz-examples/

posted on 2020-07-07 11:42  中道学友  阅读(489)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上