当前位置: > CentOS > CentOS教程 >

centos6.x误删/sbin/service的恢复方法

时间:2016-05-20 19:31来源:linux.it.net.cn 作者:IT
因为执行rm命令时,不小心误删了/sbin/service这个非常重要的系统服务启动命令,于是赶紧上网搜索,居然完全搜索不到相关文章。
下面是咨询了运维资深人员之后,给出的解决办法,现记录如下:
首先执行yum,rpm命令查看一下相关软件包

# yum list | grep initscripts
initscripts.x86_64                       9.03.31-2.el6.centos          @anaconda-CentOS-201207061011.x86_64/6.3
initscripts.x86_64                       9.03.40-2.el6.centos.1        updates
上面给出了可安装软件的yum源版本。

# rpm -qa | grep initscripts
initscripts-9.03.31-2.el6.centos.x86_64
上面是目前系统已安装的initscripts情况,因为误删了service文件,显然已经出现了错误,然后执行

# yum install initscripts
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.btte.net
* updates: mirrors.btte.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package initscripts.x86_64 0:9.03.31-2.el6.centos will be updated
---> Package initscripts.x86_64 0:9.03.40-2.el6.centos.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================

===============================================================================
Package                                   Arch                                 Version       

                                  Repository                             Size
==================================================================================================

===============================================================================
Updating:
initscripts                               x86_64                               9.03.40-2.el6.centos.1                               updates                               940 k

Transaction Summary
==================================================================================================

===============================================================================
Upgrade       1 Package(s)

Total download size: 940 k
#这里输入y
Is this ok [y/N]: y
Downloading Packages:
initscripts-9.03.40-2.el6.centos.1.x86_64.rpm          | 940 kB     00:00    
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : initscripts-9.03.40-2.el6.centos.1.x86_64                 1/2
  Cleanup    : initscripts-9.03.31-2.el6.centos.x86_64                   2/2
  Verifying  : initscripts-9.03.40-2.el6.centos.1.x86_64                 1/2
  Verifying  : initscripts-9.03.31-2.el6.centos.x86_64                   2/2

Updated:
  initscripts.x86_64 0:9.03.40-2.el6.centos.1                                                     

Complete!
安装完成后,发现service已经存在于/sbin目录下

# ll /sbin/service
-rwxr-xr-x 1 root root 1694 Feb 20 18:44 /sbin/service

# rpm -qa | grep initscripts
initscripts-9.03.40-2.el6.centos.1.x86_64
软件做了一个小版本更新。真让人虚惊一场。




(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容