12

I couldn't find an answer in the man pages for sysctl. My sysctl.conf file is still at it's default state, I'm testing several values and loaded new settings via sysctl -p newsettings.conf. I though it would be sufficient for reseting to do sysctl -p (which means that it reads the values from sysctl.conf). But a fast sysctl -a | grep domain revealed that there are still the old settings.

Any ideas?

Fleshgrinder
  • 3,638
  • 2
  • 16
  • 19

2 Answers2

17

As far as I know there is no "undo" for sysctl -- You need to re-enter the default settings (typically /etc/sysctl.conf simply does not specify defaults, so re-reading it won't revert your changes unless there's an explicit setting).

If you do not know your default settings a reboot will get them back, and you can then list them with sysctl -a (store this somewhere for reference). If you have another mostly-identical machine around you can grab the sysctl -a output from that host instead of rebooting.

voretaq7
  • 79,345
  • 17
  • 128
  • 213
  • 1
    Okay, thanks. Rebooting would be a possibility and then `sysctl -a > sysctl_defaults.conf` should do the trick. I'll leave this open for some time, maybe somebody else knows a way. If not I'll accept your answer as the correct one. – Fleshgrinder Aug 15 '12 at 20:42
  • @Fleshgrinder Make sure you're storing the sysctl values somewhere where they aren't being routinely read at boot (like `~/sysctl_defaults.conf`) -- Though it doesn't happen often sometimes the default value for a given sysctl knob changes, and you could introduce some accidental strangeness that way. – voretaq7 Aug 15 '12 at 20:59
  • 1
    Thanks, I knew that and I stored them in my home directory as you have proposed. I also made sure that nothing is in `/etc/sysctl.d` before rebooting. Everything worked like a charm and I think your solution is totally fine. Thanks again for your help. – Fleshgrinder Aug 15 '12 at 21:04
1

Sysctl Defaults

On CentOS 7, look at

/usr/lib/sysctl.d/

to get the default settings that ship with the OS.

Aaron
  • 2,809
  • 2
  • 11
  • 29