How to Fix the Ubuntu Login Loop Issue

Few things can throw you into a panic faster than trying to log into your computer and being denied entry. You click on your username. You enter your password. You hit Enter and… nothing.

Unfortunately, this kind of experience is more common than you might think with Ubuntu. The good news is that fixing this problem is not too difficult when you know what to do. If your Ubuntu system is stuck in a login loop, follow along, and we’ll have you back up and running in no time.

Get to a Terminal From the Ubuntu Login Screen

The first thing you’ll need to do is drop out of the graphical login screen and get to a terminal. To do this, boot your system as normal and wait for the login screen to appear. From the login screen, press Ctrl + Alt + F3.

Some laptops use the function keys for things like setting screen brightness or sound volume. On these machines, you may need to hold down another key to have your F3 key act as a function key and not a volume control or whatever else it might do.

Dell laptops, for example, have a key labeled Fn. On these machines, you need to press Fn + Ctrl + Alt + F3 simultaneously.

Pressing this key combination will take you to a terminal screen with a prompt for you to log in. Log in with your username and password, and you will be at a command prompt in your home directory. You can enter commands here just as you would in the terminal app from your desktop.

We recommend you try each of the following possibilities to resolve the Ubuntu login loop issue.

1. Check Ownership Settings for Configuration Files

One of the most common reasons behind the Ubuntu login loop is incorrect file ownership settings on one or two of the files that help control the login screen on some systems. They exist as hidden files in your home directory.

Enter the following at your command prompt to get a full directory listing:

ls -la

Near the end of the listing, look for a file named .Xauthority. This file may not exist on your system. If there’s no file with the name .Xauthority, just skip to the next suggestion. If the .Xauthority file does exist, look at the owner and group for the file. These two attributes appear to the left of the file name and size.

In the image above, they are highlighted and both set to root. If this file is present on your system and shows as being owned by root, this is going to be your problem. The file should be owned by you, not the root user.

To change the owner settings, enter the following command:

sudo chown username:username .Xauthority

You should, of course, enter the command and substitute “username” with your actual username. Be sure to enter the command exactly as shown. Note the colon between the two usernames, the dot at the beginning of the filename, and the capital X.

When done, list the directory again, and the file owner should now be your username.

If the .Xauthority file is set correctly, look further up the directory listing to see if a file named .ICEauthority exists. If you see this file, check its owner as well. If the owner is set to root (or any name other than your username), use the same command shown above to correct the ownership settings; simply change .Xauthority to .ICEauthority in the aforementioned command.

2. Check Permission Settings on the /tmp Directory

Another common problem that can cause the login loop issue is incorrect permission settings on the system’s /tmp directory. This directory holds all kinds of temporary files and can wreak havoc when system processes can’t get to their files.

To see the permissions on the /tmp directory, enter the following two commands:

cd /
ls -la

The /tmp directory should appear near the end of the list. Here, you want to look at the string of letters in the leftmost column of the directory listing. They represent the permissions for the directory.

In the case of /tmp, that string of letters should be exactly drwxrwxrwt. If your directory listing shows anything different, run the following command to change the file permissions:

sudo chmod 1777 /tmp

3. Check Available Free Space

Another common cause of unexpected behavior is running out of space on your hard drive. Your system will do all sorts of strange things when it can’t write to the hard drive.

To check how much free space you have, use the df command:

df -h ~

This will show you much space you have used and available on the drive that holds your home directory. If the free space is less than three or four gigabytes, you should look for files to delete. Your downloads directory is probably a good place to start.

You can also use the following command to list disk usage for the entire system:

df -h

If the results of this command show that any device has no free space left, you’ll have to figure out how to remove some files from that device or increase the partition size to open up more space.

You should be extremely careful about removing any files outside of your home directory or modifying disk partitions. Mistakes could mean losing all of your data.

4. Remove and Reinstall Your Desktop Environment

If all else fails, as a last resort, you can try removing and reinstalling the Ubuntu desktop environment (including GDM). It may take some time to complete, but you only need to enter a few commands.

To perform a fresh install of the desktop, enter the following commands in order:

sudo apt remove ubuntu-desktop
sudo apt update
sudo apt dist-upgrade
sudo apt autoremove
sudo apt clean
sudo apt install ubuntu-desktop

These commands will remove the current desktop, update the current software list, upgrade your system and packages to the latest versions, remove and clean any unused files, and, finally, re-install the desktop environment.

Reboot Your System After Each Configuration

After implementing any of the above-stated solutions, you should reboot your system and try to log in again. To do so, enter the following at the terminal prompt:

sudo shutdown -r now

At this point, you should have broken the login loop and gained access to your system again.

Although going through this experience is not pleasant for anyone, there is an important lesson to be learned. Things like this are exactly why it’s important to make regular backups of your Linux system. Sometimes there is no other solution than formatting your drive and starting over.

If you find yourself in that situation without a backup, it’s going to be painful.

[quads id=2]
Read the full article here

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button