44

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):

screenshot of ps

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

2

1 Answer 1

67
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.

2
  • So is that (nothing), nothing, "nothing", "", , '', or just what? Commented Mar 1, 2020 at 3:29
  • 3
    @Wolfpack'08 it's hard to denote "nothing" via text; sorry for the confusion. There's no replacement text after the equals-sign.
    – Jeff Schaller
    Commented Mar 4, 2020 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .