笔者近日配置openresty时误删了pcre库(/lib64/libpcre*),导致很多零碎很多指令无奈应用(如grep,vi,yumsz,rz等),因而惯例的装置没有方法修复(如yum install pcre)。上网查阅了不少材料,有光盘启动Troubleshooting的,也有举荐跑路的。特此记录一下不必跑路的办法。

yum wget等指令找回来

此时咱们无奈失常应用yum(不信能够本人检查一下)

[root@centos6102 ~]# yum -v # 查看yum是否能够应用-bash: yum: command not found

须要晓得的是,咱们只是误删了libpcre*,并没有毁坏yum等其余指令。因而,咱们能够应用相对地址来调用指令。

[root@centos6102 ~]# /usr/bin/yum -vLoading "fastestmirror" pluginConfig time: 0.008Yum Version: 3.2.29You need to give some commandUsage: yum [options] COMMAND

因而如果是在/usr/bin下的指令咱们能够应用/usr/bin/[command]来调用,在/bin下的指令能够用/bin/[command]调用,其余类推。

如果不想每次都多打一次门路,能够间接批改/etc/profile。找到上面的语句,退出咱们的门路,修复好pcre后再删除。
# Path manipulationif [ "$EUID" = "0" ]; then    pathmunge /sbin    pathmunge /usr/sbin    pathmunge /usr/local/sbinelse    pathmunge /usr/local/sbin after    pathmunge /usr/sbin after    pathmunge /sbin after        # 这里减少如下字段,修复好pcre后再删除    # fixed the libpcre problem, temporarily    pathmunge /usr/bin    pathmunge /usr/local/bin    pathmunge /usr/sharefi

下载&装置pcre

1.卸载pcre

/bin/rpm -e --nodeps pcre

2.下载pcre包(不同零碎替换成相应的源)

/usr/bin/wget http://mirrors.163.com/centos/6/os/x86_64/Packages/pcre-7.8-7.el6.x86_64.rpm

3.装置pcre

/bin/rpm -ivh pcre-7.8-7.el6.x86_64.rpm # 应用rpm装置/usr/bin/yum localinstall pcre-7.8-7.el6.x86_64.rpm # 或者应用yum

到这里,咱们就实现了修复。