User ID in Linux
To print user ID in Linux, we can use id command.
Example 1 – User Id of root user
In this example, we get the user ID of root user.
We are currently logged in as root.
To get the user ID of root user, execute the id command.
root@tutorialkart# id uid=0(root) gid=0(root) groups=0(root)
uid is our user ID. id prints group id
groups information as well, along with the user ID.
Example 2 – User ID of another user
In this example, we get the user ID of user prasanna (who is logged in right now).
Now we have logged in as another user, say prasanna.
Let us get the user ID of this user using id command.
prasanna@tutorialkart# id uid=1000(prasanna) gid=1000(prasanna) groups=1000(prasanna) ,4(adm) ,24(cdrom) ,27(sudo) ,30(dip) ,46(plugdev) ,120(lpadmin) ,131(lxd) ,132(sambashare)
In this Linux Tutorial, we learned how to get the user ID of current user using id command.