Differences between /init and /sbin/init
Andrew Henderson
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 differWhat are the differences between /sbin/init and /init?
2 Answers
/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.
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 distor image Microsoft adds own file /init.