gextra gextra - 4 months ago 18
Linux Question

Is there a way to identify the user who owns a process from /proc/PID

I am parsing process details out of

/proc/PID
and I am so far unable to find who owns a process from that meta directory's files.

Documentation does not seem to point to that info as well:

Answer

The owner of the process is the owner of all files in the /proc/PID directory.

$ ls -l /proc/27595
total 0
dr-xr-xr-x   2 me users 0 Jul 14 11:53 attr
-r--------   1 me users 0 Jul 14 11:53 auxv
...

Also the file /proc/PID/loginuid holds the UID of the owner of the process.

$ cat /proc/27595/loginuid
1000
Comments