I forgot my username, how do I get it back?

When I installed the latest update of Ubuntu, I was asked for the username but I do not remember what my username is. How do I find out what my username is?


Solution 1:

If you can not even log in because you cannot remember your username, there is still a way to recover your data. Note that this guide assumes you're the only user on the system.

  1. Boot the system into Recovery Mode through GRUB.
  2. Select the Root Shell option.
  3. Type in this command into the terminal window that opens:
    awk -F: '$3 == 1000' /etc/passwd
  4. Your username will be at the very beginning of the line on one of the returned lines. Typically there will only be one, but there may be more depending on your system.
  5. Reboot into normal mode and use the username specified.

If you are not the only user, replace the code on step 3. Look for a user with an ID greater than or equal to 1000 by:

awk -F: '$3 >= 1000' /etc/passwd

One of them is bound to be you. Or ask another user on the machine to pull the account list.

Solution 2:

Open a terminal (Ctrl+Alt+T) and type the command

whoami

to find out the user name of the user who is currently logged in.

Solution 3:

The login screen shows possible accounts and you only have to click (or even not have to click since you were presumably the last to log in) and type your password.

If you are logedin and want to know the user then Open a terminal (Ctrl+Alt+T) and type the command

echo $USER

This will print the value of USER environment variable to the console.