How can I find my User ID (UID) from terminal?

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

1

4 Answers

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 shell variable. (It is not an environment variable, and thus is not available in env).

     echo $UID
5

Simply try

id

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

3

Try also :

getent passwd username

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

Or:

grep username /etc/passwd
2

You can use id command.

Manpage

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like