I'm trying to start a VMWare Workstation VM from the command line. I can do this under my user (not root) by running the following

/usr/bin/vmplayer /home/myUser/vmware/myVm.vmx

Now, I want to set this VM to start on boot, so I created a service /lib/systemd/system/myService.service with the following:

Description=my vm service

ExecStart=/usr/bin/vmplayer /home/myuser/vmware/myVm.vmx


If I run the service from the terminal (i.e. sudo systemctl restart myService) I can see the VM window popping up and starting correctly. However, if I reboot the system the VM doesn't start and this is the status I get

Jan 23 12:55:59 home systemd[1]: Started myService service.
Jan 23 12:56:00 home truenas.sh[848]: [AppLoader] Use shipped Linux kernel AIO access library.
Jan 23 12:56:00 home truenas.sh[848]: An up-to-date "libaio" or "libaio1" package from your system is preferred.
Jan 23 12:56:00 home vmplayer[848]: cannot open display: :0
Jan 23 12:56:00 home systemd[1]: myService.service: Main process exited, code=exited, status=1/FAILURE
Jan 23 12:56:00 home systemd[1]: myService.service: Failed with result 'exit-code'.

I thought DISPLAY=:0 on the environment would fix the issue but that's the error I got and I'm not able to fix it.

  • 1
    You are installing as a system service so there is no display. You could try installing as a user service -- this will start when you login. Assuming a local login you will have a display. Alternatively you could try running your vm 'headless'. VirtualBox has this option, don't know about VMWare. Jan 23, 2023 at 18:26
  • I set it up as a user service but I get the same error. Very strange because if I just restart the service manually it works...
    – Victor
    Jan 23, 2023 at 20:44
  • Do you have the desktop file for VMWare? Jan 24, 2023 at 1:59

1 Answer 1


As @Stephen Boston pointed out in the comments you should use a systemd user service but you have to change, remove and add some directives in your unit:

  1. Change: WantedBy=multi-user.target to WantedBy=graphical-session.target
  2. Add the directives: PartOf=graphical-session.target and After=graphical-session.target in [Unit] section.
  3. Add in [Service] the directive: Type=exec
  4. You can remove Environment=DISPLAY=:0
  5. May be you want to add also this directive in [Service] section: Restart=no

So your unit would become:

Description=my vm service

ExecStart=/usr/bin/vmplayer /home/myuser/vmware/myVm.vmx


Finally place the unit under: $HOME/.config/systemd/user/ directory and to enable/start it you should use systemctl --user ....:

systemctl --user enable myService.service

systemctl --user start myService.service

You can also run apps on StartUp by using .desktop files and place them in /etc/xdg/autostart or in ~/.config/autostart. Check this answer for more details.

  • The service part didn't work for me for some reason. It doesn't give me any information other than error code 1. However, I marked your answer as resolved, since I could start the VM from the Startup Application Preferences. Thanks for the pointer!
    – Victor
    Jan 24, 2023 at 4:34
  • 1
    @Victor Glad to know some solution worked. About the error you can use journalctl --user -xeu myService.service for a more detailed log (maybe it's something related to VMware dependencies). In my case I tested with Nautilus on Ubuntu server and worked successfully. Jan 24, 2023 at 4:49

You must log in to answer this question.

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