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?


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.

  • 2
    This answer only works if the user who cannot remember its username has the UID 1000 (commonly the first non-system user). What if this is a multi-user computer and the OP is not the first user? Aug 29 '16 at 6:39
  • This guide assumes that there's only one user on the current system. You'd just cat /etc/passwd and look for the right entry.
    – Kaz Wolfe
    Aug 29 '16 at 6:41
  • I commented in order to enhance your answer ;-) If I were to suggest a user to read /etc/passwd entries grepping by UID I would go to a more general way and say "your UID is 1000 or higher, normally, if you are the only user then it's 1000, if you were the second, 1001", I think grepping for 1??? would not give too many entries, and any of the shown lines would ring a bell in the forgetful user... don't you think? Aug 29 '16 at 6:45
  • 2
    Given that the question starts "When I installed..." I think we can safely assume they are the first user. Aug 29 '16 at 7:16
  • 1
    Why not just a simple cat /etc/passwd and look for something familiar? Aug 29 '16 at 15:10

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


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

  • 9
    whoami won't help if you have alerady forgotten your user-name and logged out.
    – EKons
    Aug 29 '16 at 9:27

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.

  • 3
    Why so much hassle? whoami does the job!
    – EKons
    Aug 29 '16 at 9:28
  • Yes whoami also does the Job. Aug 31 '16 at 16:25

If you ever activated the root account, use it.

If the aforementioned recovery mode method works, use it.

If you have a live CD that can mount the filesystem of your installation, do so and indeed look up the user in the /etc/passwd file.

If none of these is viable, you can (unless you password protected your boot manager with an unknown password) still enter your system by adding the option "init=/bin/sh" to the kernel parameters (which you can edit from the boot manager menu). This should drop you straight to a simple shell after the kernel is loaded, and you can look into text files like /etc/passwd. Modifying files is not possible in that mode unless extra steps (which are dangerous if not well understood and rather out of scope here) are taken. You might have to force a reboot by power cycling to exit that mode.


You can drop into single mode from Grub. During boot, press Escon the Grub boot screen when it prompts you to. It may just show you Grub with listings of each kernel - if that's the case don't press Esc

From here select the first entry and press eto edit that entry. Page down to the line that starts with kernel and press e again.

This will allow you to edit the entire line. Scroll to the right until you reach the end and remove splash quiet from the line, replacing it with single. Press eneter to accept the changes and press b to boot into the modified kernel line. This will boot you into single user mode and should drop you into a root shell once the boot has completed.

From here you can add users to the system, change user passwords, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.