man手册、zip备份

3案例3:man手册、zip备份

3.1问题

本例要求掌握man帮助手册的使用,以及zip压缩/解压缩的操作,完成下列任务:

  1. 查阅passwd命令、/etc/passwd配置文件的手册页
  2. 使用zip打包/usr/share/doc/qemu-kvm/目录

3.2方案

zip/unzip压缩与解压缩:

  • 制作zip压缩包:zip [-r] 备份文件.zip 被归档的文档...
  • 释放zip压缩包:unzip 备份文件.zip [-d 目标文件夹]

3.3步骤

实现此案例需要按照如下步骤进行。

步骤一:使用man手册页获取帮助

1)查看passwd命令的手册页

[root@svr7 ~]# man  passwd
PASSWD(1)                      User utilities                      PASSWD(1)
NAME
       passwd - update user's authentication tokens
SYNOPSIS
       passwd  [-k]  [-l]  [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w
       warndays] [-i inactivedays] [-S] [--stdin] [username]
DESCRIPTION
       The passwd utility is used to update user's authentication token(s).
       This task is achieved through calls to the Linux-PAM and Libuser API.
       Essentially,  it initializes itself as a "passwd" service with Linux-
       PAM and utilizes configured password modules to authenticate and then
       update a user's password.
.. ..

2)查看/etc/passwd配置文件的手册页

[root@svr7 ~]# man  2  passwd
PASSWD(5)                 Linux Programmer's Manual                PASSWD(5)
NAME
       passwd - password file
DESCRIPTION
       The  /etc/passwd  file  is  a  text  file  that  describes user login
       accounts for the system.  It should have read permission allowed  for
       all users (many utilities, like ls(1) use it to map user IDs to user‐
       names), but write access only for the superuser.
       In the good old days there was no great  problem  with  this  general
       read  permission.   Everybody could read the encrypted passwords, but
       the hardware was too slow to crack a well-chosen password, and  more‐
       over  the  basic assumption used to be that of a friendly user-commu‐
       nity.  These days many people run some version of the shadow password
       suite,  where /etc/passwd has an 'x' character in the password
.. ..

步骤二:使用zip命令制作压缩包

1)将目录/usr/sharedoc/qemu-kvm/备份为/root/qemu-kvm.zip

[root@svr7 ~]# zip  -r  /root/qemu-kvm.zip  /usr/share/doc/qemu-kvm/
  adding: usr/share/doc/qemu-kvm/ (stored 0%)
  adding: usr/share/doc/qemu-kvm/COPYING (deflated 62%)
  adding: usr/share/doc/qemu-kvm/COPYING.LIB (deflated 65%)
  adding: usr/share/doc/qemu-kvm/Changelog (deflated 61%)
  adding: usr/share/doc/qemu-kvm/LICENSE (deflated 45%)
  adding: usr/share/doc/qemu-kvm/README (deflated 4%)

2)恢复测试

删除目标文件夹并确认结果:

[root@svr7 ~]# rm  -rf  /usr/share/doc/qemu-kvm/
[root@svr7 ~]# ls  /usr/share/doc/qemu-kvm/
ls: cannot access /usr/share/doc/qemu-kvm/: No such file or directory

恢复目标文件夹并确认结果:

[root@svr7 ~]# unzip  /root/qemu-kvm.zip  -d  /
Archive:  /root/qemu-kvm.zip
   creating: /usr/share/doc/qemu-kvm/
  inflating: /usr/share/doc/qemu-kvm/COPYING  
  inflating: /usr/share/doc/qemu-kvm/COPYING.LIB  
  inflating: /usr/share/doc/qemu-kvm/Changelog  
.. ..
[root@svr7 ~]# ls  /usr/share/doc/qemu-kvm/
COPYING      README                    qemu-tech.html
COPYING.LIB  README.rhel6-gpxe-source  qmp-commands.txt
Changelog    README.systemtap          qmp-events.txt
LICENSE      qemu-doc.html             qmp-spec.txt

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值