vim编辑二进制文件
第一步、以二进制方式打开文件
[root@centos7 tmp]# vim -b tree-1.6.0-10.el7.x86_64.rpm
第二步、扩展命令模式下,利用xxd命令转换为可读的十六进制
:%!xxd
第三步、插入模式下,编辑二进制文件
第四步、扩展命令模式下,利用xxd命令转回二进制
:%!xxd -r
第五步、保存退出
# 破坏文件
[root@centos7 tmp]# echo >> tree-1.6.0-10.el7.x86_64.rpm
# 校验失败
[root@centos7 tmp]# rpm -K tree-1.6.0-10.el7.x86_64.rpm
error: tree-1.6.0-10.el7.x86_64.rpm: not an rpm package
# 二进制方式打开文件并编辑
[root@centos7 tmp]# vim -b tree-1.6.0-10.el7.x86_64.rpm
# 校验成功
[root@centos7 tmp]# rpm -K tree-1.6.0-10.el7.x86_64.rpm
tree-1.6.0-10.el7.x86_64.rpm: rsa sha1 (md5) pgp md5 OK