72

How do I know my username? I've installed Ubuntu, but I don't know my username, only my password. I can't access my laptop and it can't be opened.

  • 6
    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. – Gilles Aug 17 '13 at 11:22
  • 1
    @Jayharte - did any of these answers work for you? If so, please accept one as the answer. Thank you. – Tass Dec 3 '13 at 14:37
125

Open a Terminal and type whoami

This will work on every Unix/Linux System.

  • 7
    He cannot login so I bet that he cannot run whoami – Boris Aug 18 '13 at 8:50
  • 1
    He could run it from recovery mode – rajlego Mar 4 '14 at 2:59
  • 4
    @rajlego If run from recovery mode, whoami would just output root. However, in recovery mode, ls /home could be used to view the names of the system's normally configured human users. If there's just one such user, this output is their username; and even if there are more, it should make it pretty easy to figure out the username. – Eliah Kagan Sep 6 '14 at 4:45
  • Agree with @Boris. As he mentioned in the answer, he could not login, how could he launch whoami? It's strange to have this answer got many vote-ups. – Tung Tran Dec 15 '15 at 14:16
  • 2
    @TungTran - Upvotes are from googlers (like me) who came here looking for the answer to the question in the title. Some of us just need a reminder of the command that prints out the current username. But, reading the actual question, this answer is pretty useless to the asker. – gilly3 Sep 22 '16 at 21:24
20

Most simple way to find out your username is probably to press ctr+alt+t - this opens terminal and than you will see something like:

user_name@machine_name:~$

And that answers your question.

  • So is user_name is the user name and machine_name is the group? – Rafael_Espericueta Jul 25 '16 at 20:58
  • No. Machine name is name of your computer. – Jendas Jul 25 '16 at 21:01
  • this is not always correct, as what the terminal shows is configurable – Elzo Valugi Oct 23 '18 at 15:28
  • 1
    If you can configure your terminal, you probably know the whoami command. – Jendas Nov 9 '18 at 14:30
12

If you installed ubuntu, then you filled in your username, does this help jog our memory?

E.g. here where yann is the user name

enter image description here

11

Open a Terminal and type:

echo $USER

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

  • 3
    To the original asker, this is as useless as the whoami command, but in all honesty, this is perfect for those "run a blah username_here" commands where username_here part can be replaced with $USER and the whole command made more universal. Thanks. – nurchi Sep 26 '16 at 18:42
  • 1
    @Ali Dehghani, $USER is an environment variable that can be changed to anything. whoami actually checks which is the currently logged in user – Josef Klimuk Apr 24 '18 at 6:55
6

You should boot up your Ubuntu in recovery mode. Follow the steps below:

  • Switch on your computer. Wait until the BIOS has finished loading, or has almost finished. (During this time you will probably see a logo of your computer manufacturer.) Quickly press and hold the Shift key, which will bring up the GNU GRUB menu. (If you see the Ubuntu logo, you've missed the point where you can enter the GRUB menu.) **

  • Select the line which starts with "Advanced options". *

  • Select the line ending with "(recovery mode)", probably the second line, something like: Ubuntu GNU/Linux, with Linux 3.8.0-26-generic (recovery mode)

  • Press Return and your machine will begin the boot process.

  • After a few moments, your workstation should display a menu with a number of options. One of the options (you may need to scroll down to the bottom of the list) will be "Drop to root shell prompt". Press Return with this option highlighted.

Eventually, you could use this command to list all usernames:

cut -d: -f1 /etc/passwd

I suppose you will be able to recognize your username in the list.

  • You don't need to remount,rw for just reading a file... – Germar Dec 2 '15 at 4:59
  • You're right, I just given it as an option. – Tung Tran Dec 2 '15 at 5:01
  • This will work if the user hasn't set their root password ever. However, if someone has set it already, they can always just use a live usb or any other OS to look at the home directory(hopefully unencrypted.) – Rohitt Vashishtha Dec 2 '15 at 5:22
  • Yes, if he remembers his root password, it's even easier. Anyway, as he said, he's installed the Ubuntu and doesn't know his username. I suppose he didn't set root password. – Tung Tran Dec 2 '15 at 7:03
  • Also, with single user mode, even though you set a root password, you will be able to skip it. – Tung Tran Dec 2 '15 at 7:04
5

Normally when you start your computer, you don't have to know your username to log on, because it appears automatically in a list. And if it's the only user account, it's the only name listed. It should look like this:

enter image description here

If there is more than one user account, click on the name you want to use. For just one user, all you have to do is type in your password.

If your login screen does not look like that, or logging in does not work, or the problem is that booting fails before you get to the login screen, please let us know, and provide as many details as possible.

  • 3
    Impressive edit Eliath !! – Boris Aug 18 '13 at 9:14
  • I suppose he has a problem displaying the username on the login page. If he could see the login screen, he would recognize the username. Then if so, we wouldn't ask. – Tung Tran Dec 15 '15 at 14:18
  • My username and my name are different so this won't always work. – mchid Dec 21 '15 at 3:18
2

From recovery mode, run the following command to list all human like users:

awk -F'[/:]' '{if ($3 >= 1000 && $3 != 65534) print $1}' /etc/passwd

source

1

Use this solution if you didn't encrypt your home directory.

  1. Do you still have the installation media(LiveCD/USB) from which you installed Ubuntu? Boot from it and select Try Ubuntu.

  2. Go to Files and then, you will see you already installed Ubuntu partition. Click on it, it will mount.

  3. Go to /home. Here you will see a list of all users on the system that you have created.

To jog your memory, however, what is your name? Did you enter the same name while installing Ubuntu? Do you recall the name that was displayed on the login prompt where you entered your password? Ubuntu by default sets the username as your first name in lowercase.

Example; name= John Doe, automatically set username= john

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.