96

I want user foo to auto-login using LightDM (which has been used by Ubuntu since version 11.10). How would I do that?

3
  • 5
    FYI, If you are using home folder encryption, you can't enable auto login.
    – Saeid
    Mar 30, 2013 at 8:37
  • I know its slightly off-topic: I want to mention nodm is an alternative option which can start an x session for a user on boot with no auth (thinks like the lock screen probably wont work, etc) Jun 24, 2019 at 7:03
  • nodm is no longer maintained by anybody. Jul 22, 2023 at 14:23

14 Answers 14

95

An alternative to Alin's answer is to create a file /etc/lightdm/lightdm.conf and add the following content:

[SeatDefaults]
autologin-user=<YOUR USER>
autologin-user-timeout=0
user-session=ubuntu
# Uncomment the following, if running Unity
#greeter-session=unity-greeter

Next time you start, auto-login should work like expected.

4
  • 11
    Setting autologin-user to your user name is enough for autologin to work.
    – Smile4ever
    Oct 22, 2014 at 16:47
  • 3
    On old versions there is a bug, if you set autologin-user-timeout=0 (or any other value to autologin-user-timeout), it's not working (LP#902852, debian#682473.
    – pevik
    Apr 23, 2016 at 4:48
  • 2
    @Smile4ever for my setup (debian buster 4.18 + openbox) it didn't work without autologin-user-timeout=0.
    – Vorac
    Dec 15, 2018 at 17:42
  • To specify a custom autologin-session, use e.g. autologin-session=openbox
    – spawn
    Dec 4, 2020 at 9:56
49

You can do this without editing configuration files: go to System Settings > User accounts, click "Unlock" and enter your password, then click the button next to "Automatic login":

'enter image description here

5
  • 4
    I'm working on Ubuntu 14.04. Here there is no option as "Automatic Login" as shown in your screen shot. Please say how to enable automatic login.
    – Ravi
    Sep 25, 2014 at 6:48
  • @Ravi: the option is still there in Ubuntu 14.04 and 14.10. But there's an alternative answer below for enabling this from the lightdm.conf file. Sep 26, 2014 at 11:40
  • @Ravi do you have home folder encryption on?
    – jcollum
    Jul 26, 2017 at 14:28
  • Looks a little different, but can be found in the same place and works in MATE 18.04
    – Andreas
    Feb 13, 2021 at 16:46
  • This does not work for me in Ubuntu 22. The setting is there exactly as your screenshot shows it, but it doesn't work. Creating the config file as mentioned in the other answers works for me. Jan 13, 2023 at 15:01
36

From Ubuntu 14.04 and above create the file:

/etc/lightdm/lightdm.conf.d/12-autologin.conf

and add:

[SeatDefaults]
autologin-user=youruser
3
  • 1
    I had to create this file and all it had was this and worked!
    – Peter
    Oct 20, 2014 at 12:39
  • 3
    This worked for me on 64-bit Ubuntu MATE 18.04 LTS (Bionic), as of July 2018, when editing /usr/share/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf file like I did in 16.04 LTS, did no good.
    – ablaze
    Jul 7, 2018 at 19:52
  • still works great in Ubuntu 22.04!
    – hanshenrik
    Oct 21, 2022 at 9:13
18

You can easily do this with lightdm-set-defaults if you'd rather not edit lightdm.conf manually:

sudo /usr/lib/lightdm/lightdm-set-defaults --autologin "$USER"

It will not set the autologin timeout, but the default for that is 0 in the code anyway, so you don't need to set it.

1
  • 10
    This doesn't work in 14.04 LTS as lightdm-set-defaults was removed then so the other methods are better. Aug 22, 2014 at 7:33
8
gksu gedit /etc/lightdm/lightdm.conf

add lines:

autologin-user=username
autologin-user-timeout=0

example:

[SeatDefaults]

user-session=ubuntu

greeter-session=unity-greeter

autologin-user=alan

autologin-user-timeout=0
3

Open settings, select 'user accounts'. Click the unlock button, then change the Automatic Login switch to "On"

1
  • 1
    Thank you Luyang Liu, but this optino is not displayed in User Accounts.
    – Agmenor
    Jan 17, 2013 at 18:34
2

In Ubuntu 18.04 (Xubuntu Minimal Desktop), create /etc/lightdm/lightdm.conf and add the following:

# /etc/lightdm/lightdm.conf
[SeatDefaults]
autologin-user=<username>
autologin-user-timeout=0

I couldn't get it working through the lightdm.conf.d folder.

1
  • Worked on 16.04 as well.
    – IsaacS
    Mar 14, 2019 at 4:24
1

Search for "User Accounts" application. Select the account you want to autologin Toggle the Automatic Login switch to On

That should do the work.

1

I can confirm that this works for 16.04.
Using your favourite editor, amend /usr/share/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf.
Add autologin-user=xxxx to the file, for example:

[Seat:*]
greeter-session=lightdm-gtk-greeter
autologin-user=wmurphy

Remember to also set the Not asked to login option under Users and Groups.

1

Ubuntu 20.04 How To: automatic login of particular user (e.g. server login)

autologin for Ubuntu 20.04 and Ubuntu 20.04 LTS with XFCE4 this works:

(all as root using sudo)

0) set display manager to lightdm

dpkg-reconfigure lightdm

check settings with

lightdm --show-config

1) enable login without password

under Users and Groups

set the Not asked login option for the concerned user.

2) create and edit a new file /etc/lightdm/lightdm.conf.d/01_username.conf

vim /etc/lightdm/lightdm.conf.d/01_username.conf

and set

[SeatDefaults]
autologin-user=username
autologin-user-timeout=0

replace "username" according; do NOT set autologin-user-timeout other than 0, does not work!

This solution worked fine with a nearly vanilla installation without gnome and without unity.

2
  • How can step 1) be done?
    – Foo
    Oct 2, 2021 at 17:17
  • Hallo @Paolo, good question, I missed this detail, sorry: Start CLI, invoke "users-admin". This shall start an slightly advanced GUI tool for user admin. "users-admin" should be available for all distros out of the repositories (no dodgy "downlods"). In this GUI for each user there should be a password section. Click on it and look out for some phrase about asking for login passwd. Language dependent. I can not tell you immediately how to resolve this without GUI tool from CLI, should be feasible. Some of the following tipps from other contributors do describe it. Oct 6, 2021 at 7:23
1

For kali-rolling: (may work for other kali versions)

sudo sed -i '/^\[Seat:\*\]$/a autologin-user=YOUR_USERNAME\nautologin-user-timeout=0' /etc/lightdm/lightdm.conf

then create/add yourself to autologin group

sudo groupadd -r autologin
sudo gpasswd -a username autologin

and reboot.

the command uses a seds insert after regular expression match feature to insert the line needed in the right section, you can alternatively just edit the file and add autologin-user= in the Seat section.

1
  • Does also work with Arch, the user have to be in a group named autologin Feb 1 at 2:32
0

I have 12.10 xubuntu. In users and groups choose your user, and click word "Change..." next to "Password:" (it does not look like a button, what might be a bit misleading). There you can change password, or at the bottom mark "Don't ask for password on login" box.

Hope it works.

1
  • Thank you very much Chris. However, as explained in my question, this solution is not displayed in User Accounts.
    – Agmenor
    Jan 17, 2013 at 18:34
0

I just discovered that, I need to have ubuntu-desktop to be install before lightdm could function. This solved my issue when trying to get lightdm to actually login in without going in loop.

The reason for the system to go in loop may be because lightdm needs the ubuntu desktop before it may work.

sudo apt-get install ubuntu-desktop
2
  • This is absolutely wrong, since I'm using lightdm with openbox environment only Sep 19, 2017 at 14:54
  • Can you point to a link for how to do this? I had set lightdm.conf user-session=LXDE, then switched that to openbox as per /usr/share/xessions/openbox.desktop, but it keeps starting LXDE.
    – naasking
    Sep 4, 2018 at 11:40
0

I had the same problem, I solved it with the following steps:

  1. login as root: sudo su
  2. enter the file:

    sudo nano /usr/share/lightdm/lightdm.conf.d/60-lightdm-gtk-greeter.conf
    
  3. at the bottom add:

    autologin-user=xxxx
    
  4. save the content of the file then exit and reboot.

This should definitely work.

0

You must log in to answer this question.

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