As a common practice, users are required to provide authentication information to log on to a Linux system. This helps in securing any sensitive or personal files, emails and other data residing on your system from any physical intrusion. However, if your system is placed at an already secure location, free from any privacy threat, you may avoid the hassle of providing your user credentials every time you log in. This article provides you with the following two ways to enable/disable automatic login to your Ubuntu system:
- Through the command line.
- Through the graphical interface.
Please note that we are running this tutorial on an Ubuntu 18.04 LTS (Bionic Beaver) system.
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:
- Open the Terminal through Ubuntu Dash or by pressing Ctrl+Alt+T.
- 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:
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.
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.
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:
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.
Provide authentication details through the following dialog and click Authenticate:
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.
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.