[How To] Find your forgotten username on Ubuntu

Sometimes, it so happens that after creating a unique user for a new Ubuntu install, you completely forget the username. If you are a single user on a Ubuntu machine, physical or virtual, you can easily recover the username without firing up the Ubuntu Live CD. Here are the steps:

1. Restart your machine and go to the Grub menu. ( If you do not see the grub menu, hold the shift key down to get it)

2. Select the “Recovery mode” (2nd option from the top) on the list
3. From the recovery menu, select the option “Drop to root shell prompt”

4. Once on root, use the following command  
    cat /etc/passwd | grep /bin/bash

The above command will show the users in Ubuntu which has a folder in the /home directory and uses /bin/bash. Usually it will be the root user and the users you have created. From there you can easily find the username.
If that’s too much to understand, just open the file /etc/passwd with nano text editor using the command nano /etc/passwd. Usually the last entry in the file is your username. Once finished, press Ctrl + X to exit from the nano text editor. 
This method can also be used if you have multiple users and you cannot remember one of the usernames.
The procedure mentioned above has been tested on Ubuntu 12.04 .1 LTS

Leave a Reply

tuxtrixmod
Scroll to Top