I'm trying to grab the owner of a process from a list, I have the command pidof nmap to get the then ps -u <PID> | grep USER that I'm currently playing around with, but when I run it, it ends up just printing the titles (top line).

enter image description here

How can I grab the name of the owner given the process ID?

ps -o user= -p PIDHERE

This selects the process PIDHERE with -p, then instructs ps to format the output by printing only the column named user; the = sign means "rename the column user to (nothing)", effectively removing the header line.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.