How to restore the accidentally deleted/sbin/service from centos
When executing the rm command, I accidentally deleted the very important System service Startup command/sbin/service by mistake. So I searched the internet and couldn't find any related articles.
The solutions provided after consulting with senior O & M personnel are as follows:
First, run the yum and rpm command to check the related software packages.
[Html] view plaincopy
- # Yumlist | grepinitscripts
- Initscripts.x86_649.03.31-2.el6.centos@anaconda-CentOS-201207061011.x86 _ 64/6. 3
- Initscripts. x86_649.03.40-2.el6.centos.1updates
The yum source version for software installation is provided above.
[Html] view plaincopy
- # Rpm-qa | grepinitscripts
- Initscripts-9.03.31-2.el6.centos.x86_64
The preceding figure shows the initscripts already installed in the system. Because the service file is deleted by mistake, an error is displayed, and then run
[Html] view plaincopy
- # Yuminstallinitscripts
- Loadedplugins: fastestmirror
- Loadingtransferspeedsfromcachedhostfile
- * Base: mirrors.btte.net
- * Extras: mirrors.btte.net
- * Updates: mirrors.btte.net
- SettingupInstallProcess
- ResolvingDependencies
- --> Runningtransactioncheck
- ---> Packageinitscripts. x86_640: 9.03.31-2. el6.centoswillbeupdated
- ---> Packageinitscripts. x86_640: 9.03.40-2. el6.centos. 1 willbeanupdate
- --> FinishedDependencyResolution
- DependenciesResolved
- ========================================================== ========================================================== ========================================================== ========================================================== ========================
- PackageArchVersionRepositorySize
- ========================================================== ========================================================== ========================================================== ========================================================== ========================
- Updating:
- Initscriptsx86_649.03.40-2.el6.centos.1updates940k
- TransactionSummary
- ========================================================== ========================================================== ========================================================== ========================================================== ========================
- Upgrade1Package (s)
- Totaldownloadsize: 940 k
- # Enter y here
- Isthisok [y/N]: y
- DownloadingPackages:
- Initscripts-9.03.40-2.el6.centos.1.x86_64.rpm | 940kB00: 00
- Runningrpm_check_debug
- RunningTransactionTest
- TransactionTestSucceeded
- RunningTransaction
- Updating: initscripts-9.03.40-2.el6.centos.1.x86_641/2
- Cleanup: initscripts-9.03.31-2.el6.centos.x86_642/2
- Verifying: initscripts-9.03.40-2.el6.centos.1.x86_641/2
- Verifying: initscripts-9.03.31-2.el6.centos.x86_642/2
- Updated:
- Initscripts. x86_640: 9.03.40-2. el6.centos. 1
- Complete!
After the installation is complete, it is found that the service already exists in the/sbin directory.
[Html] view plaincopy
- # Ll/sbin/service
- -Rwxr-xr-x1rootroot1694Feb2018: 44/sbin/service
- # Rpm-qa | grepinitscripts
- Initscripts-9.03.40-2.el6.centos.1.x86_64
The software has made a minor version update. This is a real surprise.