Skip to content
Advertisement

Converting euid and egid to username and group name

I looked at some of my system logs and its claiming about errors that apply to random effective user id’s and group id’s. For example:

JavaScript

I’m just wondering if theres a simple command I can use in the shell to identify the real username and group ID based on the numbers (which in this example is 47 and 12).

I know I can get away with using the chown command with those numbers (via chown 47:12 item) then ls to find out the user ID and group name, but I think there’s a simpler way somehow and I can’t figure out what it is.

I just want to be able to type on the command line something like:

JavaScript

and have it print out the username and group the user belongs to.

What command do I use?

Advertisement

Answer

You can use the id command to get information about a user:

JavaScript

You will get the username and every group the user belongs to.

Example:

JavaScript

man id for more information 😉

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement