1.zip和uzip命令
1)基本语法:zip +xxx.zip 要压缩的文件名
unzip +xxx.zip
zip命令:
-c:替每个被压缩的文件加上注释
-d:从压缩文件内删除指定文件
-r:递归压缩
-x:压缩时去除某个不需要的文件
例子:
[root@zcf test]# zip tangshi.zip tangshi
adding: tangshi (deflated 60%)
[root@zcf test]# ll
total 12
-r------w-. 1 root root 0 Jul 23 11:39 file1
-rw-r--r--. 1 root root 273 Jul 12 16:37 tangshi
-rw-rw-r--. 1 root root 553 Jul 28 11:04 Tangshi.txt
-rw-r--r--. 1 root root 273 Jul 29 13:55 tangshi.zip
[root@zcf test]#
-r:-x
[root@zcf home]# zip -r test.zip test -x /test/file1
adding: test/ (stored 0%)
adding: test/tangshi (deflated 60%)
adding: test/Tangshi.txt (deflated 84%)
adding: test/tangshi.zip (stored 0%)
adding: test/Tangshi.zip (stored 0%)
-d:
[root@zcf home]# zip -d test.zip test/tangshi
deleting: test/tangshi
zipnote:可以查看压缩包中的文件名
[root@zcf home]# zipnote test.zip
@ test/
@ (comment above this line)
@ test/Tangshi.txt
@ (comment above this line)
@ test/tangshi.zip
@ (comment above this line)
@ test/Tangshi.zip
@ (comment above this line)
@ (zip file comment below this line)
unzip命令:
unzip -v 查看压缩文件夹/目录但不解压
-o:不必询问用户,uzip执行后覆盖原有文件
-x:指定不要处理.zip压缩文件中那些文件
2.gzip和gunzip
1)基本语法:gzip +文件名
uzip+压缩文件名
3.打包归档命令tar
打包是将一大堆文件或目录变成一个总的文件;压缩则是将一个大的文件通过一些算法变成小文件。
参数:-c:建立压缩档案
-x:解压
-t:查看内容
-r:向压缩文件末尾追加文件
-z:有gzip属性的
-j:有bz2属性的
-v:显示所有过程
-f:使用档案名字,切记这个是最后的一个参数
tar -cvf :仅打包,不压缩
tar -zcvf :打包后,以gzip压缩
tar -jcvf:打包后,以bzip2压缩
4.转换或者拷贝文件dd
dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换。
1.if=文件名:输入文件名
2.of=文件名:输出文件名
例如:
将本地的/dev/hdb备份到/dev/hdd
dd if=/dev/hdb of=/dev/hdd