文件的压缩与解压

来源:互联网 发布:sql数据库打不开 编辑:程序博客网 时间:2024/04/30 01:03

文件的压缩与解压
1.常见格式
.tar .tar.gz .tgz .gz .Z .bz2

2.命令汇总
compress 古老的压缩命令
gzip
BZIP2
tar

3.
1).compress uncompress

2).gzip -cdtv# file

压缩后源文件将丢失
gzip -v a.txt

zcat a.txt.gz

解压
gzip -d a.txt.gz

要想保留源文件 使用 -c 并重定向

3).bzip2
bzip2 相比 gzip 多了一个 z 参数,代表压缩

4).tar
文件夹打包,还是 tar 比较强大
tar -cvf
-t 显示目录结构吧
-jz 压缩
-C 特定目录解压锁

-p 保留权限属性
-P 可包含根目录
–exclude 不包含
–newer-time=’2017-01-01’

tar -tf en.gz
tar -xvf en.gz ./haha/o.txt

find /etc -newer /etc/passwd
tar -czvf ~/test.gz –newer-mtime=”2017/01/09” /etc/*

5).dump
备份文件系统或者目录

df -h备份时间dump -S /dev/sdc1备份等级,完全备份    dump -0u /dev/sdc1    cat /etc/dumpdates  备份记录备份记录dump -Wdd if=/dev/zero of=/boot/test.file bs=1M count=10dump -0u -f /root/ha.2 /boot对与非文件系统的目录dump -0j -f /root/hah /etc

6) restore
restore -t -f dumpfile -h dump归档查看
restore -C -f dumpfile -D 比较
restore -i -f dumpfile 互动模式
restore -r -f dumpfile 还原整个文件系统

0 0