How to get LightDM automatically started at startup after disabling it (in Ubuntu MATE)?

24,300

Solution 1

An enabled service should have a symlink to the unit file in /lib/systemd/system in /etc/systemd/system. The systemctl enable command should create that symlink, but in this case it fails for some reason. The correct symlink is:

$ ll /etc/systemd/system/display-manager.service
lrwxrwxrwx 1 root root 35 okt  7 00:20 /etc/systemd/system/display-manager.service -> /lib/systemd/system/lightdm.service

You can fix it by recreating the symlink yourself:

sudo ln -s /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service

Tested in Ubuntu MATE 16.04.

Solution 2

Reconfiguring LightDM worked for me (xubuntu 18.04):

sudo dpkg-reconfigure lightdm

Solution 3

You have to run sudo systemctl set-default graphical.target because if multi-user.target is set as default you can not use the GUI.

Share:
24,300

Related videos on Youtube

NewOne
Author by

NewOne

Updated on September 18, 2022

Comments

  • NewOne
    NewOne over 1 year

    I am working with Ubuntu MATE (16.04) on a Raspberry Pi 3. I disabled LightDM with

    sudo systemctl disable lightdm
    

    On the next boot LightDM did not show up again and instead I just got a terminal asking me for my credentials, what was exactly what I wanted. When I am log in and type

    startx
    

    the grapical sessions shows up, so far so good.

    Now I want to get LightDM back after boot and so I tried reenabling it with

    sudo systemctl enable lightdm
    

    The output is:

    Synchronizing state of lightdm.service with SysV init with /lib/systemd/systemd-sysv-install...
    Executing /lib/systemd/systemd-sysv-install enable lightdm
    

    But when I now reboot my system, LightDM does not show up again. What went wrong?

    In addition to that, when I just log in in terminal and type

    sudo systemctl start lightdm
    

    LightDM is started normally, i.e. the graphical session is started and the login screen is shown. How can I get LightDM started automatically after boot again?

    • TheOdd
      TheOdd over 7 years
      You could write the command that works in a script and have it auto run on start.
    • NewOne
      NewOne over 7 years
      Thanks for your fast answer. That should work, but I find this solution kind of nasty. And I want to know why ''sudo systemctl enable lightdm' does not do the job...
  • Gunnar Hjalmarsson
    Gunnar Hjalmarsson over 7 years
    Thanks for sharing that, @Zanna. Please feel free to edit the answer.
  • NewOne
    NewOne over 7 years
    Thanks, this solved the problem. When creating the symlink as you described, LightDM is automatically started after boot again. Is it a bug that systemctl enable does not create the symlink ?
  • Gunnar Hjalmarsson
    Gunnar Hjalmarsson over 7 years
    @NewOne: Don't know if it's a bug. From "man systemctl" about "enable": "This command expects either valid unit names (in which case various unit file directories are automatically searched for unit files with appropriate names), or absolute paths to unit files (in which case these files are read directly). If a specified unit file is located outside of the usual unit file directories, an additional symlink is created, linking it into the unit configuration path, thus ensuring it is found when requested by commands such as start."
  • Berkant Ipek
    Berkant Ipek almost 5 years
    Works for Ubuntu MATE 18.04.
  • ZimaXXX
    ZimaXXX almost 4 years
    Works for Raspbian GNU/Linux 10 (buster)