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:

Jan 31 13:20:48 server exim[24551]: 2016-01-31 13:20:48 Cannot open main log file "/var/log/exim_mainlog": Permission denied: euid=47 egid=12

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:

convertstuff 47:12

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:

id 47

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

Example:

$ id 74

> uid=74(sshd) gid=74(sshd) groups=74(sshd)

man id for more information 😉

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