Disable autologin in Ubuntu

After installing Ubuntu on a stick the system will let you in without asking for a password. What happens is that the display manager LightDM will auto-login the built-in ubuntu user.

While for many people it may seems convenient and fast I would like to have the system protected by a password. If you think like me then please keep reading to find out how to do it. It took me a lot of trials and errors and even if it is not a perfect solution it works for me.

My first idea was to disable the auto-login for ubuntu user and set a password which I had to type in order to log in. This did not work – for some reason the password kept resetting between the restarts and although I had to type the username (ubuntu) I was able to just press the Enter key and log in.

At the end I did the following:

Step 1)
Set a password for the root account:

You have to type the password twice. I know it is not recomended but this is my system and I want it that way.

Step 2) Create a new user that you would use most of the times. I will call it joe for example. The best way to create it is to cick the gear icon in the top right corner of the screen and then choose System Settings… -> User Accounts. The click the plus sign (lower left). In the new dialog choose the account type – Standard or Administrator. Type the Full Name and Username. When ready click the Add button.

We have to set a password for this accound and to add it to the sudo group. Open a terminal and type:

You have to type the password twice.

Step 3) Disable autologin for ubuntu account and enable the manual login

The configuration file that we have to edit is /etc/lightdm/lightdm.conf and initially should look like this:

Screenshot from 2014-12-05 22:41:34

Open the file in your favourite text editor and add the following line to enable the manual login:

You also need to comment out the autologin-user=ubuntu line by inserting the # sign in the front. Your configuration files should look like this:

Screenshot from 2014-12-06 22:15:08

Step 4) Lock the ubuntu account

Open a terminal and type:

The account will be locked and you cannot use it to login. This means we have two accounts we can use to log in – root and joe.

By default LightDM only shows the user-created accounts on the login page. When you restart the system you will see the user joe which you can click on and type the password in order to login. In addition to that you should see the text Login. If you click it you will be able to type a username, press Enter and then type the password. You can use this way to log in with the root user.

In both cases you are protected by a password. I hope this helps you.

Tagged with: ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.