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.
- Boot the system into Recovery Mode through GRUB.
- Select the Root Shell option.
- Type in this command into the terminal window that opens:
awk -F: '$3 == 1000' /etc/passwd
- 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.
- 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.
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
This will print the value of USER environment variable to the console.
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
From here select the first entry and press
eto edit that entry. Page down to the line that starts with
kernel and press
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
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.