Linux的打包命令

在Linux里,免不了要对网站的程序目录等进行打包压缩的备份,一般用到的是tar命令,当然还有cpio.

tar

tar命令可以用来压缩打包单文件、多个文件、单个目录、多个目录。

常用格式:

单个文件压缩打包 tar czvf my.tar  file1

多个文件压缩打包 tar czvf my.tar  file1 file2,…

单个目录压缩打包 tar czvf my.tar  dir1

多个目录压缩打包 tar czvf my.tar  dir1 dir2

解包至当前目录:tar xzvf my.tar

一个实例:tar -zcvf mysql.tar.gz /home/

cpio

含子目录find x* | cpio -o > /y/z.cpio

不含子目录ls x* | cpio -o > /y/z.cpio

解包: cpio -i < /y/z.cpio

This entry was posted in 系统 and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>