2

I managed to totally lose my ability to log into the only non guest account on my personal Ubuntu machine.

I am learning more about linux and I was reading about virtual consoles which I was struggling to understand.I opened up a terminal and started playing around in the /dev directory to try to understand what was going on with the tty devices.

first I redirected stdout from an echo to dev/null for a baseline I then did the same to dev/random I then did the same to dev/tty1

All is good up to this point, as far as I can tell.

I then typed sudo X to see what happened when I tried to create another instance of X. at this point I get thrown to a black terminal

the terminal is prompting me

dev's login: password:

but my normal login info doesn't work. I am not quite sure what to put for the login piece I tried the username and password of my main account and it said invalid credentials.

I then restarted assuming this would be the end of my trouble. Now when I get to my login and submit my normal credentials, I get a flash of the black console and then it just throws me back to the login page with no errror.

I'm hoping this may be an obvious fix to someone with linux experience.

1
  • Can you boot into single user mode? There are no passwords there.
    – Christopher Ian Stern
    Jun 2, 2015 at 3:42

1 Answer 1

3

The command you ran was most likely

sudo startx

which changed permissions for files in your home directory (~), including a file called .Xauthority which is vital to the X Server. It is now owned by root and cannot be read - But it's needed for a successful login, as you might have noticed. Now you know, but nonetheless: Don't run startx with root permissions!

To fix the permissions, we need to access a command line without X Server. But that's no problem. The "terminal prompt" you saw is a non-graphical "user interface". To switch to one, press Ctrl+Alt+F1. You will see the same login prompt. You need to put in your username, press Enter and put in your password.

If you are not sure about your username (as there is a "display name" visible most of the time, if you defined one), switch back to the graphical login via Ctrl+Alt+F7 and log in as guest. Take a look at the /home directory via your file manager - There is a directory named the same as your username.

Go back to your terminal login prompt, type in your username and your password. I cannot help you with figuring out your password, but I hope you remember it. Be sure your keyboard layout is correctly configured (for example while being asked for your username).

Now, we'll fix permissions. It's pretty straightforward, just run

sudo chown -R $(id -u -n):$(uid -u -n) /home/$(id -u -n)

$(id -u -n) will be replaced with your username when the command is running. Of course, you can replace them by hand if you want, but it will work either way. If you want to know what exactly happened, look up the chown command.

Now switch back to login (Ctrl+Alt+F7) and you should be able to log in just fine.

1
  • 1
    I wish I could upvote this!! This is a great answer! Very detailed and explains the solution as well as why that solution works. Thanks again!
    – Andrew
    Jun 3, 2015 at 20:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .