47

Is there a way to know if the kernel was compiled with a certain option activated (i.e. CONFIG_PROC_EVENTS=y) without having to pull out the kernel sources package and looking in the config file?

Evan Carroll
  • 28,578
  • 45
  • 164
  • 290
Alicia
  • 1,652
  • 2
  • 17
  • 19

4 Answers4

40

If you look through your /boot directory you'll notice these files:

$ ls -l /boot/|grep config
-rw-r--r--  1 root root   109919 Oct 21  2011 config-2.6.35.14-100.fc14.x86_64
-rw-r--r--  1 root root   109919 Oct 27  2011 config-2.6.35.14-103.fc14.x86_64
-rw-r--r--  1 root root   109919 Nov 23  2011 config-2.6.35.14-106.fc14.x86_64

Notice what version of the Kernel you're using:

$ uname -r
2.6.35.14-106.fc14.x86_64

If you grep through the appropriate "config-uname -r" file you can see what options the Kernel was built with:

$ grep CONFIG_PROC_EVENTS= /boot/config-`uname -r`
CONFIG_PROC_EVENTS=y

References

slm
  • 363,520
  • 117
  • 767
  • 871
  • 10
    That's true in Debian based distros, but may not be true in others, i.e. Arch Linux. – Alicia Jul 17 '13 at 06:56
  • 1
    @ntrrgc - I can't confirm for ArchLinux, but it's that way for RedHat, Debian, & Ubuntu. These 3 distros cover *most* of the *nix world. If someone has a ArchLinux distro can you please confirm this approach? – slm Jul 17 '13 at 11:24
  • 5
    I use Arch Linux and I can confirm this does not work in Arch Linux. – Alicia Jul 17 '13 at 15:31
  • @slm this isn't even true for Ubuntu, at least Kubuntu. I just checked — the only thing I have in `/boot/` is `grub` directory. – Hi-Angel Nov 24 '15 at 15:52
  • @slm perhaps are these configs a part of some package? Then it would be enough to list files of that package. – Hi-Angel Nov 24 '15 at 16:02
  • @Hi-Angel - this is a 2+ year old question and the output I showed was from a Fedora 14 system which at the time was how most distros that make use of grub worked. Things have changed now with grub2. – slm Nov 24 '15 at 16:08
  • Hm, I found a pretty interesting thing — I actually found where the file supposed to be with `dpkg -S "config-3"`. And this is… `/boot/config-3.13.0-66-generic` *(well, one of the files)*. However the directory doesn't contain them. Weird… – Hi-Angel Nov 24 '15 at 16:17
  • Checked with Ubuntu 16.04 and it works – Anwar Oct 12 '16 at 08:39
  • Not existing such files on Ubuntu nor Kali for RaspBerry. – Sopalajo de Arrierez Oct 05 '17 at 23:21
  • These files don't exist for Raspbian, either. There is a /boot/config.txt with an entirely different function. – Phil Frost Jun 08 '20 at 02:34
26

Kernel options can be found in /proc/config.gz.

zgrep CONFIG_PROC_EVENTS= /proc/config.gz

if the kernel was compiled with CONFIG_IKCONFIG_PROC=y. If the kernel was compiled with CONFIG_IKCONFIG_PROC=m, then it may be necessary to first modprobe configs.

Phil Frost
  • 538
  • 1
  • 3
  • 14
Alicia
  • 1,652
  • 2
  • 17
  • 19
  • 1
    This did not work for me on any of the distros that I had available: Debian, RedHat based, nor Ubuntu. These are all stock systems so I don't think this approach is that useful unless you built your kernel yourself or your particular distro provides it. – slm Jul 17 '13 at 11:25
  • 8
    In distro kernels, the IKCONFIG option may be enabled only as a module. Try to `modprobe configs` and check if /proc/config.gz shows up. – XZS Sep 05 '13 at 15:21
5

If your kernel was build with CONFIG_IKCONFIG_PROC, you can find the configuration listed in /proc/config.gz

zless /proc/config.gz

Debian and Redhat based kernel packages generally install a config-$version file in /boot,

less /boot/config-$(uname -r)

In Debian you can also find the default options in kernel-package's ./kernel/Config/config as well as architecture specific configuration options in ./kernel/Config/.

mkdir /tmp/k
cd /tmp/k
apt-get source kernel-package
find . -path '*/kernel/Config/*' -type f
Evan Carroll
  • 28,578
  • 45
  • 164
  • 290
1

sudo find / -xdev -name .config(-xdev keeps it on one filesystem)

Generally it will be under /usr/src/some-specific-kernel-header-version/.config

Just read it as any text, search with grep, or to see how two versions differ diff -y -suppress-common-lines /path/linux2.6-r3/.config /path/linux2.6-r4/.config

Max Power
  • 229
  • 1
  • 9
  • 2
    Well, dangit. Someone gave Max a -1, but out of all the methods here, it worked on my RHEL7 machine. So, I have no choice: +1. I found my file at `/usr/src/kernels/3.10.0-1062.el7.x86_64/.config` – Mike S Aug 05 '21 at 16:30
  • 1
    @MikeS I think I was on Debian at that answer date, but I was using CentOS7 not long before. – Max Power Sep 30 '21 at 20:47