I am using WSL2.
When I run the code :
systemctl start ssh
or any command with
systemctl in it, it shows
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
WSL doesn't use systemd as the init system to boot distributions. That's in part because systemd typically starts a lot of services that WSL doesn't need and don't makes sense in a WSL context (such as ones mounting additional file systems), so WSL uses its own init system.
systemctl, as you've seen, can't be used to start services if systemd wasn't the init system that booted the OS. The solution is to use the much more portable
service ssh start. This should usually work on Debian-based distributions where the service descriptions aren't always provided as systemd init scripts. Kali is just such a distribution.
service command also works on other distros as well, but many Red Hat- and Fedora-based distros don't provide anything but systemd units, so while the
service command will work when systemd is being used, there's no alternative scripts to use when systemd isn't enabled and you can't start services except by hand in that case.