5

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?

2 Answers 2

8

/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.

2
  • 2
    You're right that it's unusual to find /init on the rootfs, however, it would be completely normal to find one inside an initramfs... Commented May 31, 2020 at 7:34
  • @Claude /init, it's in the official Ubuntu WSL2, downloaded as default from Windows Store. Shouldn't be an issue. However, i guess /init is used by kernel instead of /sbin/init-->/lib/systemd/systemd, and I can't use systemctl
    – Dan D.
    Commented May 31, 2020 at 8:04
2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .