md5sum程序的应用

来源:岁月联盟 编辑:exp 时间:2012-03-14
检查文档是否变动过
1、以root身份登录到linux系统
 
2、在根目录下创建文件夹md5test
  cd/
  mkdir md5test
 
3、进入md5test目录:cd md5test
 
4、创建名为myfile的文件:touch myfile
 
5、使用vi编辑myfile文件,输入以下内容:
 
  Has anyone altered the contents of this file?
 
6、使用md5sum计算hash校验和
 
  [root@md5test]#md5sum myfile
 
7、再次运行md5sum命令,并且将结果导出保存到myfile.md5文件中
 
  [root@md5test]md5sum myfile>myfile.md5
 
8、打开myfile文件,修改文件内容(尽量作最小的改动)然后保存
 
9、再次运行md5sum命令,应该得到以不同的hash值
 
10、用cat命令查看myfile.md5内容:cat myfile.md5
 
11、比较第9步和第10步的输出结果,应该看到两者的不同
------------------------------------------------------------------------------------
12、输入以下命令:md5sum /etc/passwd >passwd.md5,创建针对当前/etc/passwd
  数据库的hash校验值
 
13、查看passwd.md5文件内容:cat passwd.md5
 
14、添加用户hashtest并且修改密码
 
  Linux#useradd hashtest
 
  Linux#passwd hashtest
 
  Changing password for user hashtest
 
  Nes UNIX password:
 
  Retype new UNIX password:
 
  passwd:all authentication tokens updated successfully
 
15、执行命令md5sum -c passwd.md5,其中-c参数用来比较数据库更改前后的hash 校验值,应该能够看到有关校验值已经改变的信息