The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
printing each users by processes sam4now Shell Programming and Scripting 12 04-28-2008 06:11 PM
Processes and Users barbus Shell Programming and Scripting 22 10-03-2007 07:09 PM
users and there processes iago UNIX for Dummies Questions & Answers 3 09-10-2007 02:51 PM
i need a scipt to email users with idle processes!? sheppy28 Shell Programming and Scripting 0 02-02-2007 04:08 PM
Displaying the processes of users olimiles Shell Programming and Scripting 2 08-18-2006 02:57 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-15-2006
Chiefos Chiefos is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 28
Users and processes

Hi All,

I am trying to write a script to list all users and their processes. I cant seem to find out how to link the PID to the user. For example if i run ps -a I get a nice list of all the processes running and their PID, but no information about which user is running them.

If i use w i can see what the users are running but no reference to the PID, which i need. Basically I need to find PID, User, and tty. If i could link the PID to a user then i could simpley grep the PID lines from the ps -a return and get what I want, but I dont know how to find this info.

Thanks, Chris.
  #2 (permalink)  
Old 06-15-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
This may help you:
Code:
ps -ef | grep username
  #3 (permalink)  
Old 06-15-2006
grial's Avatar
grial grial is offline Forum Advisor  
El UNIX es como un toro
  
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
This depends on the version of ps you are using (X/Open or Berkeley) but, from man ps:

Code:
-o Format Displays information in the format specified by the Format variable.
Multiple field specifiers can be specified for the Format variable. The Format
variable is either a comma-separated list of field specifiers or a list of field
specifiers enclosed within a set of " " (double-quotation marks) and separated
from one another by a comma or by one or more spaces, or both.
This way you can select which information you want ps to display.
  #4 (permalink)  
Old 06-17-2006
Chiefos Chiefos is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 28
shereenmotor: ps -ef doesnt output the username at all, it does however output the UID, which still doesnt help because I need to link the UID to a username.

grial: ps -O will work, but i dont know what format I would need for my question.
  #5 (permalink)  
Old 06-17-2006
Chiefos Chiefos is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 28
Basically:

ps -ef

This gets me all the information I need except the username. Though it does return the users ID (UID). I need to know how I reference the username from the UID.


Thanks, Chris.
  #6 (permalink)  
Old 06-17-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
take a UID and scan/map from '/etc/passwd'
  #7 (permalink)  
Old 06-17-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 578
can you pls post the output of: ps -ef and ps -O both here?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:59 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0