od 输出文件的八进制十六进制的字节
rev 以行为单位反转字符串
第4章
tar 归档实用工具 打包 解压缩
No 1 2 3 4 5 6
命令/参数 tar -cvf bin.tar /bin [root@bogon ~]# file bin.tar bin.tar: POSIX tar archive tar -xvf bin.tar tar -czvf bin.tar.gz /bin tar -xzvf bin.tar.gz 作用 将bin目录下的所有文件打包,包名为bin.tar并显示打包详细过程。打包完成bin.tar在当前目录下 用file命令探测bin.tar的类型为:POSIX tar的归档包 解压bin.tar 打包并进行gzip压缩 [root@bogon ~]# file bin.tar.gz bin.tar.gz: gzip compressed data, from Unix, 探测bin.tar.gz的类型 last modified: Sun Dec 30 18:40:46 2012
gzip 压缩 解压缩
No 1 2
命令/参数 gzip demo3.txt gzip -d demo3.txt.gz 作用 压缩后发现demo3.txt没有了,取而代之的是demo3.txt.gz 查看文件的详细可以发现,压缩后比原来的文件小了 解压包demo3.txt.gz gunzip 解压缩gizp指令压缩的包
No 1
命令/参数 gunzip demo3.txt.gz 解压缩 作用 bzip2 创建和管理用bzip2指令压缩的包
bunzip2 解压缩bzip2创建的压缩包
cpio 存取归档包中的文件
No 1 2 3 find /bin -print find /bin -print | cpio -o > bin.bak [root@localhost ~]# file bin.bak bin.bak: cpio archive 命令/参数 bin.bak为归档包文件 作用 输出bin目录下的文件全路径 dump 备份linux文件系统
No 1 2
restore -tf bin.bak 命令/参数 dump -f bin.bak /bin 作用 备份bin目录,备份文件名为:bin.bak 查看备份文件中的文件列表 restore 还原备份 dump指令的备份
restore
[root@www ~]# restore -t [-f dumpfile] [-h] <==用来察看 dump 檔 [root@www ~]# restore -C [-f dumpfile] [-D 挂载点] <==比较dump与实际档案 [root@www ~]# restore -i [-f dumpfile] <==进入互动模式 [root@www ~]# restore -r [-f dumpfile] <==还原整个文件系统 选项与参数:
相关的各种模式,各种模式无法混用喔!例如不可以写 -tC 啦!
-t :此模式用在察看 dump 起来的备份文件中含有什么重要数据!类似 tar -t 功能; -C :此模式可以将 dump 内的数据拿出来跟实际的文件系统做比较, 最终会列出『在 dump 档案内有记录的,且目前文件系统不一样』的档案; -i :进入互动模式,可以仅还原部分档案,用在 dump 目录时的还原!
-r :将整个 filesystem 还原的一种模式,用在还原针对文件系统的 dump 备份; 其他较常用到的选项功能:
-h :察看完整备份数据中的 inode 与文件系统 label 等信息 -f :后面就接你要处理的那个 dump 档案啰!
-D :与 -C 进行搭配,可以查出后面接的挂载点与 dump 内有不同的档案!
用 restore 观察 dump 后的备份数据内容
restore -t -f boot.dump
Dump date: Tue Sep 4 01:40:00 2012 Dumped from: the epoch
Level 0 dump of /boot on Server.Sjz:/dev/sda1 Label: none 2 .
11 ./lost+found 2049 ./grub 22 ./grub/grub.conf 12 ./grub/splash.xpm.gz 23 ./grub/menu.lst 24 ./grub/device.map 25 ./grub/stage1 26 ./grub/stage2 27 ./grub/e2fs_stage1_5 28 ./grub/fat_stage1_5 29 ./grub/ffs_stage1_5 30 ./grub/iso9660_stage1_5 31 ./grub/jfs_stage1_5 32 ./grub/minix_stage1_5 33 ./grub/reiserfs_stage1_5 34 ./grub/ufs2_stage1_5 35 ./grub/vstafs_stage1_5 36 ./grub/xfs_stage1_5 2050 ./efi 18 ./efi/EFI 19 ./efi/EFI/redhat 20 ./efi/EFI/redhat/grub.efi
13 ./.vmlinuz-2.6.32-220.el6.i686.hmac 14 ./System.map-2.6.32-220.el6.i686 15 ./config-2.6.32-220.el6.i686 16 ./symvers-2.6.32-220.el6.i686.gz 17 ./vmlinuz-2.6.32-220.el6.i686 21 ./initramfs-2.6.32-220.el6.i686.img 比较差异并且还原整个文件系统
[root@Server boot]# restore -C -f /home/liyong/boot.dump Dump date: Tue Sep 4 01:40:00 2012 Dumped from: the epoch
Level 0 dump of /boot on Server.Sjz:/dev/sda1 Label: none filesys = /boot
restore: unable to stat ./config-2.6.32-220.el6.i686: No such file or directory Some files were modified! 1 compare errors
[root@Server boot]# restore -C -f /home/liyong/boot.dump Dump date: Tue Sep 4 01:40:00 2012 Dumped from: the epoch
Level 0 dump of /boot on Server.Sjz:/dev/sda1 Label: none filesys = /boot
另外还可以 仅还原部分档案的 restore 互动模式restore -i -f /home/liyong/boot.dump
compress 压缩指令 压缩后的后缀为.z
uncompress 解压.Z的压缩包
zip 压缩打包 后缀为.zip
No 1 zip bin.zip /bin/* 命令/参数 作用 压缩bin目录,压缩文件名为:bin.zip unzip 解压后缀为.zip的压缩包
bin目录是存放所有指令和二进制文件的目录,如果删除linux系统就无法启动了,所