-3

We accidentally overwrote file /sbin/sysctl with command echo 1 > /sbin/sysctl

How do we restore the file in centos?

Rahul
  • 1
  • 1
    From your backups of course.., or use `rpm -qf /sbin/sysctl` to determine which rpm package to reinstall? – HBruijn May 22 '17 at 19:50
  • Hi, I am absolute newbie. But here is what I have understood from your commend. ( Please confirm if the understanding is correct ) Step 1: executed rpm -qf /sbin/sysctl O/P: procps-ng-3.3.10-10.el7.x86_64 Step 2: I should run below command yum reinstall procps-ng-3.3.10-10.el7.x86_64 Right? Does it have any impact on already running server applications like apache / mysql etc? or any other impact on live production system. – Rahul May 22 '17 at 20:53
  • 1
    Installing procps is probably safe, but if you're worried wait for a maintenance window. – chicks May 22 '17 at 20:54

2 Answers2

4

To expand on HBruijn's comment, here's a sequence of commands that should get that file (and anything else from the same package) back. Note that you need to use yum reinstall as yum install will just tell you that the package is already up-to-date.

[root@centos7-01 msmtp]# rpm -q -f /sbin/sysctl
procps-ng-3.3.10-10.el7.x86_64

[root@centos7-01 msmtp]# yum reinstall procps-ng
...
Installed:
  procps-ng.x86_64 0:3.3.10-10.el7

Complete!
Paul Haldane
  • 4,517
  • 1
  • 21
  • 32
  • Thanks Paul Its truly a great help. But as I am an absolute newbie would like to understand if these commands would have any impact on live applications such as apache and mysql running on the same machine, Its a production machine :S – Rahul May 22 '17 at 20:54
  • Getting below error `[root@vij ~]# yum reinstall procps-3.2.8-30.el6.x86_64 Loaded plugins: fastestmirror Setting up Reinstall Process Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://apt.sw.be/redhat/el6/en/mirrors-rpmforge error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'apt.sw.be'" * base: mirror.fibergrid.in * epel: kartolo.sby.datautama.net.id * extras: mirror.fibergrid.in * updates: mirror.fibergrid.in http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'apt.sw.be' ` – Rahul May 22 '17 at 21:11
  • Ah, now that's a different problem, @Rahul. Fix your DNS resolution. :) – Jesse Adelman May 22 '17 at 23:49
1
  • Reinstall the RPM.
  • Copy it from another system.
  • Restore the file from your backups.
ewwhite
  • 197,159
  • 92
  • 443
  • 809
  • Getting below error [root@vij ~]# yum reinstall procps-3.2.8-30.el6.x86_64 Loaded plugins: fastestmirror Setting up Reinstall Process Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://apt.sw.be/redhat/el6/en/mirrors-rpmforge error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'apt.sw.be'" * base: mirror.fibergrid.in * epel: kartolo.sby.datautama.net.id * extras: mirror.fibergrid.in * updates: mirror.fibergrid.in http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repo‌​md.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'apt.sw.be' – Rahul May 22 '17 at 21:28