6

In Linux boot order, the kernel will execute /sbin/init, however, I can see another file /init existing in the file system on my linux (CentOS 8 WSL2, Ubuntu 20 WSL2).

They are different binaries:

$ diff /init /sbin/init
Binary files /init and /sbin/init differ

What are the differences between /sbin/init and /init?

gavenkoa
  • 2,154
Dan D
  • 759

2 Answers2

9

/usr/sbin/init or /sbin/init is the executable starting the SysV initialization system. For compatibility reason, when systemd is installed, it's an alias to an executable of the systemd world.

The executable /init is unusual, in a Linux system. I suggest to investigate the reasons why it's present. It could be the part of a malware.

Romain
  • 105
3

You mentioned WSL 2. Microsoft still runs special Linux kernel inside VM and because the goal is not to strictly emulate they introduced own custom init process: like what's the point to start cron/cups/X/etc in every distro you installed.

Microsoft altered init process to avoid useless resource consumption (according to expected use cases of WSL 2).

When you import a Linux distro image Microsoft adds own file /init which is shared among all distros!

Even more: according to How does WSL/WSL2/WSLg work without systemd? WSL 2 is utilizing a single VM to run all distros. So the kernel is the same and the instance of the kernel in memory is shared, separation is done though Linux namespaces.

gavenkoa
  • 2,154