-7

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
3
  • The error message makes it clear: systemctl is a sysemd command. However, you have not booted in to the systemd init system. Most likely, you're booting in to SysV init system. The OS can only boot in to a single init system--the init system is what makes the rest of the OS work with the Linux kernel. You will need to install and switch over to systemd to use that command, or find an older site with information on what you want to do that is aimed at SysV init. – C. M. Apr 23 at 15:42
  • Wow - A large number of downvotes without much explanation, so @Anu, perhaps I can shed some light on it ... – NotTheDr01ds Apr 23 at 23:59
  • 2
    As a new user here, I highly recommend you familiarize yourself with the How do I ask a good question page that is linked when you ask your question, which says, "Search, and research -- Have you thoroughly searched for an answer before asking your question? Sharing your research helps everyone. Tell us what you found and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and above all, it helps you get a more specific and relevant answer!" – NotTheDr01ds Apr 24 at 0:00
0

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 command: 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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.