大网数据广告活动
服务器运维问答

Default values on missing procfs and sysctl settings

· 52CE 我爱测

I have several questions regarding the handling of procfs or sysctl values. Can a feature be enabled with a missing /proc file? Does a missing /proc or sysctl entry always mean that the option is not enabled on that particular ke…

问题原文

原帖链接 · user5626466 · CC BY-SA 3.0

I have several questions regarding the handling of procfs or sysctl values.

Can a feature be enabled with a missing /proc file?

Does a missing /proc or sysctl entry always mean that the option is not enabled on that particular kernel? In other words: Can a feature be enabled or supported by a kernel without a corresponding /proc entry being available? I assume nobody changed the kernel source in a way to remove the code part that populates /proc.

If it can - does it default to a specific value?

I'd like to know if /proc values default to a value if the corresponding proc-File doesn't exist. If for some reason my kernel supports aslr, but /sys/kernel/randomize_va_space doesn't exist, does that result in aslr being active or not?

Is the behaviour the same for all settings?

Is the behaviour the same for all kernels, versions and features? Or do I have to get this information for each setting individually?

For example:

If /proc/sys/kernel/sysrq doesn't exist on my machine, does that mean

  1. that the Magic SysRQ feature is not available on my kernel?

  2. that it is available?

  3. that it could be available or not depending on some other option that is unknown to me?

  4. that the specific code for this feature contains a hard-coded default and this setting is different for each feature on the kernel? So if I want to know what value it defaults to, I have to take a look at to code for each feature.

There is good documentation available where I can read about the meaning of the kernel settings. Is there a document that explains the default behavior?

已采纳解答

原帖链接 · shodanshok · CC BY-SA 3.0

/proc and /sys directories are for exposing the "tuning knobs" of the Liunx kernel. It is entirely possible, albeit quite rare, to have some working kernel features without any entries in /proc or /sys - for example, if that kernel feature does not have any parameters, nor has anything to publish to the user, no entries are required.

However if the kernel documentation has some entries documented/referenced but you can not find them, two possibilities arise:

  • you are using an old kernel, without these knobs;
  • you are not using a vanilla kernel - ie your kernel is more or less heavily customized by someone (yours distro maintainer, probably).

If you think some features are enabled on your kernel but you can not find any entries in /proc and /sys, give a look at your kernel config file (often available via a file in /boot or in /proc/config.gz)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-05-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。