centos6.x误删除/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命令用法的朋友,请参考文章:
上面给出了可安装软件的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:
initscriptsx86_649.03.40-
2.el6.centos.1updates940 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 kB00: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
软件做了一个小版本更新。
另外,有详service命令的用法,可以参考:centos网络基本命令全解(service、ifconfig、netstat)