设置系统参数的 sysctl 选项之间的差异

设置系统参数的 sysctl 选项之间的差异

我在网上看到两个不同的命令来加载 sysctl 自定义参数:

  • sysctl --system
  • sysctl -p

这两个命令有什么区别吗?我知道我发布的第二个可以采用要加载的文件的路径,但如果没有指定任何文件,所有内容都会被加载。

答案1

sysctl --system从所有配置文件加载设置。

将从sysctl -p默认加载设置/etc/sysctl.conf

man sysctl:

   -p[FILE], --load[=FILE]
          Load in sysctl settings from the file specified or /etc/sysctl.conf if none given.  Specifying - as  filename  means
          reading  data from standard input.  Using this option will mean arguments to sysctl are files, which are read in the
          order they are specified.  The file argument may be specified as regular expression.

   --system
          Load settings from all system configuration files. Files are read from directories in the following  list  in  given
          order from top to bottom.  Once a file of a given filename is loaded, any file of the same name in subsequent direc‐
          tories is ignored.
          /etc/sysctl.d/*.conf
          /run/sysctl.d/*.conf
          /usr/local/lib/sysctl.d/*.conf
          /usr/lib/sysctl.d/*.conf
          /lib/sysctl.d/*.conf
          /etc/sysctl.conf

相关内容