Enable or Disable Automatic login in Ubuntu 22.04

We see the login manager or display manager once boot process completes. At the login manager, we are asked to verify ourselves by providing user credentials. Although, we don’t recommend but some may choose to disable this feature. They simply don’t want to provide username and password for some reason. Similarly, if they change their decisions later. They may restore the changes made. So, we will see here how we can enable or disable automatic login in Ubuntu 22.04 release.

Since, this is in display manager’s ambit. Therefore, we need to check which display manager we have. Thereafter, we would make changes to it accordingly. We cover only LightDM, GDM and SDDM here.

Note: Following operations would require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Identify default display manager

First, identify the default display manager using any of the command below –

cat /etc/X11/default-display-manager

or,

systemctl status display-manager

The cat command and the arguments (/etc/X11/default-display-manager) above would show anyone of the following –

/usr/sbin/lightdm
/usr/bin/sddm
/usr/sbin/gdm3

The above output is self-explanatory. Whichever is our default display manager, it would return with that particular output.

systemctl status display-manager – would show us the currently active display manager service, which in turn is our default display manager.

Once, we identify our default display manager. Next step is to edit its configuration file. Read the section which is applicable for you. We have covered all three below.

Enable or Disable automatic login for LightDM

Create a configuration file, lightdm.conf if it doesn’t exist using touch command-line utility –

sudo touch /etc/lightdm/lightdm.conf.d/lightdm.conf

We have used nano text editor to edit –

sudo nano /etc/lightdm/lightdm.conf.d/lightdm.conf

And, append the file with the following, to enable automatic login

[Seat:*]
autologin-user=<user_name>
autologin-user-timeout=0

To disable automatic login, comment the above code in /etc/lightdm/lightdm.conf.d/lightdm.conf

#[Seat:*]
#autologin-user=<user_name>
#autologin-user-timeout=0

where, <user_name> should be the user for whom you want to enable or disable automatic login.

Enable or Disable automatic login for SDDM

Again, create a configuration file if it doesn’t exist –

sudo touch /etc/sddm.conf

And, append the file with the following to enable automatic login

[Autologin]
User=<user_name>

To disable automatic login, simply comment the above code in /etc/sddm.conf –

#[Autologin]
#User=<user_name>

where, <user_name> should be the user for whom you want to enable or disable automatic login.

Enable or Disable automatic login for GDM

Edit the following configuration file with a text editor, we have used nano

sudo nano /etc/gdm3/custom.conf

Uncomment the following code from the custom.conf and enter <user_name> to enable automatic login –

# AutomaticLoginEnable = true
# AutomaticLogin = <user_name>

After removing #, it should be –

AutomaticLoginEnable = true
AutomaticLogin = <user_name>

To disable automatic login, use the following code –

AutomaticLoginEnable = false
AutomaticLogin = <user_name>

where, <user_name> should be the user for whom you want to enable or disable automatic login.

In conclusion, we have discussed how to enable or disable automatic login in Ubuntu 22.04 release.