I have always learned that the init process is the ancestor of all processes. Why does process 2 have a PPID of 0?
$ ps -ef | head -n 3 UID PID PPID C STIME TTY TIME CMD root 1 0 0 May14 ? 00:00:01 /sbin/init root 2 0 0 May14 ? 00:00:00 [kthreadd]
First, “ancestor” isn't the same thing as “parent”. The ancestor can be the parent's parent's … parent's parent, and the kernel only keeps track of one level. However, when a process dies, its children are adopted by init, so you will see a lot of processes whose parent is 1 on a typical system.
Modern Linux systems additionally have a few processes that execute kernel code, but are managed as user processes, as far as scheduling is concerned. (They don't obey the usual memory management rules since they're running kernel code.) These processes are all spawned by
Processes 1 (
Linux also has some facilities for the kernel to start user processes whose location is indicated via a sysctl parameter in certain circumstances. For example, the kernel can trigger module loading events (e.g. when new hardware is discovered, or when some network protocols are first used) by calling the program in the