Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

The title says it all. What command I need to run from a terminal to find my user ID (UID)?

share|improve this question
Use echo $UID? –  Louis Matthijssen May 17 '14 at 13:17
TAq's or Jobin's answer may be better. :) –  Louis Matthijssen May 17 '14 at 13:21

4 Answers 4

up vote 21 down vote accepted

There are a couple of ways:

  1. Using the id command you can get the real and effective user and group IDs.

    id -u <username>

    If no username is supplied to id, it will default to the current user.

  2. Using the enviroment variable.

    echo $UID
share|improve this answer

Simply try


This will return your user ID, group ID, and all your groups.

share|improve this answer
or id -u to see just the UID –  steeldriver May 17 '14 at 13:21
Yepp. Prefer Jobin's answer, if you need to avoid parsing the output. –  TAq May 17 '14 at 13:25

Try also :

getent passwd username

This will display user id , group id and home directory .


grep username /etc/passwd
share|improve this answer
why to try long or alternative command while echo $UID and id -u is simple and exact according to question? –  Pandya May 17 '14 at 13:37
thats right , but its good to know all options –  nux May 17 '14 at 13:38

You can use id command.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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