Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to check user id when running ps

Status
Not open for further replies.

Connors

MIS
Nov 23, 2007
1
GB
Hi :
I am new to unix, and some one has asked the question I don't know the answer; the question is - How can you find the user group id when you use ps command?

thanks Connors
 
hi connors,

I think you'll have to look up the users group id in the /etc/passwd file

take the users name from the ps output, and then grep for it in /etc/passwd like this

grep mike /etc/passwd

the first number is the user-id, the second is the users primary group-id Mike
"Experience is the comb that Nature gives us after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
For example, entry from /etc/passwd

userid:*:104:20:Name,,,:/home/homedir:/usr/bin/sh

Thus the 20 is the group-id.

cheers
George
 
Try this script

for process in `ps -ef | tail +2 | cut -c12-19`
do
owner=`ps -fp | tail +2 | cut -c1-8`
echo ""
echo "OWNER "$owner
echo "GROUP "`id -gn $owner`
echo "PROCESS "`ps -p |$process | tail +2`
done

I havn't tried this on HP, so you may need to modify the 'cut' values and maybe the 'ps' options.
The 'tail +2' eliminates the header lines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top