0

There are a lot of configuration files in /etc. Some of them are used by installed applications like samba, but is there confs that are directly looked up by the kernel? For example passwd, groups, hostname and so on? And if so which of them are directly for the kernel?

3 Answers3

1

None: the kernel doesn’t read any configuration file directly. Various tools read configuration files and set things up in the kernel (e.g. sysctl) but the kernel itself doesn’t.

Stephen Kitt
  • 434,908
  • I'd even have written any file of any sort. Even kernel modules don't. – MC68020 Jan 21 '23 at 16:55
  • @MC68020 the kernel does read init off its own bat, so it’s not quite “any file of any sort”. – Stephen Kitt Jan 21 '23 at 19:55
  • Granted! I'm being pedantic! (since init's main is part of linux kernel's distribution) But… well… Stephen… strictly speaking… the kernel does not "read init off its own bat"… since only init, instanced as a process will do_execve(getname_kernel(init_filename) ;-) – MC68020 Jan 21 '23 at 21:36
  • This being a little more than a subtle nuance since… the kernel (and drivers) reading any sort of any file an any point would open the kernel to unimaginable reliability / security flows. – MC68020 Jan 21 '23 at 23:27
  • What about request_firmware then? It runs in a process context, but everything happens in kernel mode, initiated by the kernel. (As does init loading, incidentally.) – Stephen Kitt Jan 22 '23 at 08:22
0

A few words about the Linux kernel and its role.

By itself the kernel does literally nothing. I'm not joking. When you load it, it tries to initialize your hardware and then it tries to execute /sbin/init from the root filesystem (something which is mounted at /), that's it. There's a caveat though.

The kernel itself is a large amount of algorithms which provide API (translation of userspace calls into something which the hardware knows what to do with) for applications to work with and even then those applications don't use these APIs directly, they call them via a middle-man such as, e.g. glibc (C language APIs) or Mesa (OpenGL, Vulkan APIs).

Speaking of the caveat earlier.

The kernel can be instructed to do work via e.g. iptables, nftables to process network packets but then the kernel doesn't generate those packets, it either receives them from outside or sends them as a result of running applications requesting to send them. One minor exception is ping which sort of kinda looks like the kernel is doing work but in order for ping to work, userspace has to instruct the kernel how to configure network. When the kernel boots, there are no network protocols at all.

  • As per my comments in Stephen's answer, the kernel does not "try to execute /sbin/init" or whatever unknown code. – MC68020 Jan 21 '23 at 23:31
  • WDYM? https://github.com/torvalds/linux/blob/master/init/main.c#L1569 (normally defined as /sbin/init - check any distro's .config) https://github.com/torvalds/linux/blob/master/init/main.c#L1578 – Artem S. Tashkinov Jan 21 '23 at 23:39
  • Yes indeed Artem. You are correct. But… you are quoting init's process code. Not kerrnel's code. – MC68020 Jan 21 '23 at 23:44
  • I'm half asleep, please edit my answer if I'm wrong. I no longer understand anything - perhaps I'm stupid as well :-) – Artem S. Tashkinov Jan 21 '23 at 23:46
-1

@Stephen Kitt already provided a good answer, but if you would like to know to which utility/package the file belons to, you can try something like this.

Debian based with deb packages:

find /etc/ -type f -exec dpkg -S {} \;

RedHat based with RPM packages:

find /etc/ -type f exec rpm -qf {} \;

Command will find all files in /etc/ directory and run a query for each file to which package the file belongs to. You will see there will be no result for kernel (or linux-image) package.

nobody
  • 1,710