How to Enable/Disable Automatic Login in Ubuntu 20.04 LTS

It is common practice for users to have to provide authentication information in order to log on to a Linux system. This helps protect sensitive or personal files, emails, and other data that reside on your system from any physical intrusion. However, if your system is in an already secure location that is free from any privacy threat, you can save yourself the trouble of providing your user credentials every time you log in. In this article, we will show you two ways to enable/disable automatic login to your Ubuntu system:

  • Through the command line.
  • Through the graphical interface.

Please note that we have tested this tutorial on Ubuntu 20.04 LTS and Ubuntu 18.04 LTS.

Enabling/Disabling Automatic Login through the Command Line

As a superuser, you can enable automatic login for yourself or for any other Ubuntu user by making some configuration changes in the custom.conf file as follows:

  1. Open the Terminal through Ubuntu Dash or by pressing Ctrl+Alt+T.
  2. Open the custom.conf file in the Nano editor through the following command:
$ sudo nano /etc/gdm3/custom.conf

Please note that you need to be a superuser in order to edit most of the system configurations.

When you enter your password, the following file will open:

Open /etc/gdm3/custom.conf in editor

In this file, the selected lines have been commented out. We can identify a commented-out line by the presence of a # character at the start of the line. The interpreter ignores the commented lines when reading through a configuration file. This means that in our file, the automatic login feature for user1 has been disabled.

Enable Automatic Login For a User

You can simply remove the # character from the last two lines we have selected and provide the username instead of the value “user1” for the user whose automatic login you want to enable.

For example:

Enable automatic login

In this tutorial, we have replaced the value user1 by sana. You can see the change in color of the now enabled feature.

Now save the file by pressing Ctrl+X and then Y.

Now when you restart the computer, the specified user will be logged in without being asked to provide any authentication details.

Disable Automatic Login For a User

In order to disable automatic login for a certain user, you can simply comment out(add a # character) the lines in the custom.conf lines where AutomaticLoginEnable=true and Automatic Login=[user1] has been specified.

Disable automatic login

You can see the change in color of the now disabled feature. Please save the file by pressing Ctrl+X and then Y. Now when you restart the computer, the specified user will be asked to provide authentication details for logging in.

Enabling/Disabling Automatic Login through the GUI

You can enable/disable automatic login for yourself or for any other Ubuntu user through the graphical interface as follows:

Click the downward arrow located on the top-right corner of your Ubuntu screen and then click your username. The following options will be displayed:

Account settings options

Select the Account Settings option.

The following Users dialog will open. Since you need to be a superuser to configure these settings, the Automatic Login button will be disabled by default. Click on the Unlock button located at the top-right side of the dialog to enable this button.

Users dialog in Ubuntu

Provide authentication details through the following dialog and click Authenticate:

Authenticate yourself to get superuser permissions

You can now switch the Automatic Login button to OFF or ON depending on whether you want to enable or disable a user’s automatic log in.

Switch automatic login on

When you restart your computer, the login authentication procedure will depend on the choice you made here.

By following the simple steps described in this tutorial, you can enable/disable automatic login facility for yourself or for other users(as an administrator). This way you can set security access to your computer depending on your needs.