Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 59 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
How about GID ? – kangear Oct 29 '15 at 1:11
@kangear id -g <username> – itsazzad Dec 18 '15 at 15:23

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.