You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the instructions from DigitalOcean to install the LAMP stack on WSL, but I found that I cannot use systemctl to control the server programs (including but not limited to Apache and Nginx).
After installing Apache, I tried using systemctl to start Apache server but it did not work.
$ sudo systemctl start apache2
Failed to connect to bus: No such file or directory
PS. systemctl list-units also outputs the same error.
Though I can still start it with sudo service apache2 start or sudo /etc/init.d/apache2 start, I'm curious about if systemctl will be supported in Ubuntu on Windows in the near future? Thanks.
Version: Windows 10 Insider Preview Build 15002
Reacted by texnicii, Dror Levin, Menelaos Kotsollaris, Megakoresh, Morgz, rektide, Ed Lomonaco, Olivier Duquesne, Ser Shu, Umesh .A Bhat and 22 more
open("/sys/fs/kdbus/0-system/bus", O_RDWR|O_NOCTTY|O_CLOEXEC) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/run/systemd/private"}, 22) = -1
ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/dbus/system_bus_socket"}, 33) = -1
ENOENT (No such file or directory)
Starting dbus (sudo service dbus start) will get you a little further but in short no systemd no systemctl.
I found in another related issue that WSL has its own init, so upstart doesn't exist, neither. Even if sudo service ... works, what it invokes is init.d scripts, but not upstart?
Not sure. All of that legacy-init-transition-related stuff is being sorted out by the distros. Upstart used to map the "service" command to upstart, which managed the init scripts. Since the switch to systemd, Ubuntu has replaced upstart with a mix of "native unit files" (i.e. little .ini-looking files that instruct systemd how to launch daemons) and classic-style-init-init scripts, which are controlled through the systemd-sysvcompat module of systemd.
For daemons of the second type, you can manually run the init.d scripts as before, not sure how they have aliases the old upstart commands. But otoh, for daemons controlled with native unit files, you will have to manually start the actual daemon executables by themselves or with your own custom 'init' scripts (depending on the daemon, this could be easy or could be hard).
It seems like some of the basic building blocks for using systemd for init are being added into WSL. The team has quietly added things like the cgroups fs, and the NT kernel has apparently always supported namespaces, two key features used by systemd. Ben Hillis also mentioned in his interop video and blogpost that Microsoft's init process (which sets up quite a bit of the magic) could probably be moved out of pid 1 and into a non-init role in the future.
I'll let you speculate about what that could mean. The devs here are very sphinx-like about future plans until they have been announced officially or at least until someone like Alex Ionescu has reverse engineered the surprise to the point where it is public knowledge. 🙃
Facing this problem too, but does it because of the windows itself blocking? Spent whole day to figure it how to auto run the nginx server, cause everytime i close the terminal, this process will turn off, it become useless..
There is so much things could happen if bash could do everything.
This is frustrating, I was so confused why I couldn't get Ajenti installed and working. This really seems like something that should work, even if Bash needs to remain open.
Jacob Bearce (@JacobDB) easier said than done, I think. They will at least need to stub out a cgroups implementation and convert the current /init to a service that gets launched by systemd. We actually have not heard a lot since CU released apart from the new mounting feature.
You may want to try using Upstart to run and manage third-party services
Also, Follow me on linkedIn , I am going to publish an article very soon on WSL and running opensource project with WSL. Hopefully, it should give you a comprehensive guide while you start working with WSL
Reacted by Jonathan Duggan, Ali Lahijani, Reslav Hollós, Marín Alcaraz, Kari Alatalo, Kim, Aron Lilland, rektide, Nuno André, Zeust the Unoobian and 41 more
Reacted by Ethan Moffat, Cody Swartz, Johann Valenzuela, Nuno André, Denis Soto, Andrés García, Nick R, Bilal MEDDAH, Victor Alves, r0g3r0g3r and 5 more
It doesn't seem to work when I use lxssmanager to restart wsl. Unit services are not auto-loaded. Why?
systemd is not actually running using this method (and can't run on WSL1, regardless). This method replaces the systemctl command with a script that reads the service unit files and follows the instructions inside to start/stop services. There is no overarching service manager daemon running in the background in this scenario.
Therefore, auto-loading services can't happen, because there is nothing to auto-load them. Just run the normal start command - if you need to start a bunch of services at once, make a bash script with a bunch of start commands in it.
wsl -t Ubuntu can not refresh systemd PID , need restart systemd . You can do
in wsl sudo sed -i 's/systemd = true/systemd = false/g' /etc/wsl.conf
in powsershell wsl -d Ubuntu
then restart wsl , after open systemd
in wsl sudo sed -i s/systemd = false/systemd = true/g /etc/wsl.conf
in powsershell wsl -t Ubuntu wsl -d Ubuntu
Activity
therealkenc commentedon Jan 10, 2017
Starting dbus (
sudo service dbus start) will get you a little further but in short nosystemdnosystemctl.#994.
fpqc commentedon Jan 10, 2017
Systemd isn't running and won't run without major changes tothe initialization process.
Edit: therealkenc lol, Systemd in Ubuntu is still trying to use kdbus?
hungys commentedon Jan 11, 2017
fpqc Thanks. That makes sense.
I found in another related issue that WSL has its own init, so upstart doesn't exist, neither. Even if
sudo service ...works, what it invokes isinit.dscripts, but not upstart?fpqc commentedon Jan 11, 2017
Not sure. All of that legacy-init-transition-related stuff is being sorted out by the distros. Upstart used to map the "service" command to upstart, which managed the init scripts. Since the switch to systemd, Ubuntu has replaced upstart with a mix of "native unit files" (i.e. little .ini-looking files that instruct systemd how to launch daemons) and classic-style-init-init scripts, which are controlled through the systemd-sysvcompat module of systemd.
For daemons of the second type, you can manually run the init.d scripts as before, not sure how they have aliases the old upstart commands. But otoh, for daemons controlled with native unit files, you will have to manually start the actual daemon executables by themselves or with your own custom 'init' scripts (depending on the daemon, this could be easy or could be hard).
It seems like some of the basic building blocks for using systemd for init are being added into WSL. The team has quietly added things like the cgroups fs, and the NT kernel has apparently always supported namespaces, two key features used by systemd. Ben Hillis also mentioned in his interop video and blogpost that Microsoft's init process (which sets up quite a bit of the magic) could probably be moved out of pid 1 and into a non-init role in the future.
I'll let you speculate about what that could mean. The devs here are very sphinx-like about future plans until they have been announced officially or at least until someone like Alex Ionescu has reverse engineered the surprise to the point where it is public knowledge. 🙃
Arios509 commentedon May 27, 2017
Facing this problem too, but does it because of the windows itself blocking? Spent whole day to figure it how to auto run the nginx server, cause everytime i close the terminal, this process will turn off, it become useless..
There is so much things could happen if bash could do everything.
JacobDB commentedon Jun 16, 2017
This is frustrating, I was so confused why I couldn't get Ajenti installed and working. This really seems like something that should work, even if Bash needs to remain open.
fpqc commentedon Jun 16, 2017
Jacob Bearce (@JacobDB) easier said than done, I think. They will at least need to stub out a cgroups implementation and convert the current /init to a service that gets launched by systemd. We actually have not heard a lot since CU released apart from the new mounting feature.
seadonfrank commentedon Nov 14, 2017
You may want to try using Upstart to run and manage third-party services
Also, Follow me on linkedIn , I am going to publish an article very soon on WSL and running opensource project with WSL. Hopefully, it should give you a comprehensive guide while you start working with WSL
yecril71pl commentedon Dec 31, 2017
servicecallssystemctlin openSUSE, so we are back to square 1.khanguslee commentedon Apr 9, 2019
You might be able to try replacing
/usr/bin/systemctlwith https://github.com/gdraheim/docker-systemctl-replacement/blob/master/files/docker/systemctl.pybimimicah commentedon Aug 28, 2019
Like Angus Lee (@khanguslee) says above, you can work around the issues with
systemctlby replacing it with Guido U. Draheim (@gdraheim)'s script.just do the following (assumes
/usr/bin/systemctl) :ctsstc commentedon Oct 15, 2019
I had to curl it down into my current directory and then sudo move it to the bin directory. I also didn't start with one to begin with.
curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > ./systemctl sudo mv systemctl /usr/bin/systemctl chmod +x /usr/bin/systemctlzfk513 commentedon Nov 6, 2019
i can't start the service as well,but can list the service
zfk513 commentedon Nov 6, 2019
how to start a service?pls tell me ,after start command it didn't reply
[-]systemctl doesn't work in Xenial[/-][+]systemctl doesn't work [/+]bayeslearnerold commentedon Mar 6, 2021
It doesn't seem to work when I use lxssmanager to restart wsl. Unit services are not auto-loaded. Why?
bimimicah commentedon Mar 8, 2021
systemd is not actually running using this method (and can't run on WSL1, regardless). This method replaces the systemctl command with a script that reads the service unit files and follows the instructions inside to start/stop services. There is no overarching service manager daemon running in the background in this scenario.
Therefore, auto-loading services can't happen, because there is nothing to auto-load them. Just run the normal start command - if you need to start a bunch of services at once, make a bash script with a bunch of start commands in it.
gochev commentedon Apr 4, 2022
As a workaround you can use the distrod https://github.com/nullpo-head/wsl-distrod
However the python script might works fine but it doesn't work for MySQL when I tried.
petrprikryl commentedon Apr 22, 2022
Hi, is there any official information about this https://bugs.launchpad.net/ubuntu/+source/wsl-setup/+bug/1962556? I couldn't find how to activate experimental support of systemd on Ubuntu 22.04 which is now available for WSL 2.
haosmos commentedon Apr 24, 2022
I'm also interested in learning about this.
petrprikryl commentedon Sep 21, 2022
https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
gochev commentedon Sep 26, 2022
I have been using distroid from few months works like charm to install on WSL2:
curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"chmod +x install.shsudo ./install.sh install/opt/distrod/bin/distrod enableor you can even do
/opt/distrod/bin/distrod enable --start-on-windows-bootnot sure if the last one is even available with the systems in wsl by Microsoft but if you cant upgrade or want to use it asap.. this works perfectly.
hoyien commentedon Mar 20, 2024
wsl -t Ubuntu can not refresh systemd PID , need restart systemd . You can do
in wsl
sudo sed -i 's/systemd = true/systemd = false/g' /etc/wsl.confin powsershell
wsl -d Ubuntuthen restart wsl , after open systemd
in wsl
sudo sed -i s/systemd = false/systemd = true/g /etc/wsl.confin powsershell
wsl -t Ubuntuwsl -d Ubuntubenhillis commentedon May 18, 2026
systemd is now supported in WSL. Enable it by adding the following to
/etc/wsl.confand restarting the distribution (wsl --shutdown):Docs: https://learn.microsoft.com/windows/wsl/systemd. Please reply with logs if you hit a specific systemd issue we can investigate.