Monday, December 19, 2011

Re: [LINUX_Newbies] PS -u Command

On Mon, Dec 19, 2011 at 09:56, kc9nsa <mike@mikesigler.com> wrote:
> Im trying to do a PS –u for PID's running under certain users.  The problem im having is;  the users have numeric usernames ex: 6545   and it won't display the pids running under numeric usernames.   Any text username displays all the pids running under that username, but not for the numeric usernames.
>
> Any thoughts?

THe actual User NAMES are numeric, or are you refering to each user's UID?

For example:


bladernr@klaatu:~/development/trunks/checkbox$ ps -U bladernr |head -5
PID TTY TIME CMD
334 ? 00:01:50 chrome
2375 ? 00:00:02 gnome-keyring-d
2384 ? 00:00:05 gnome-session
2430 ? 00:00:00 ssh-agent
bladernr@klaatu:~/development/trunks/checkbox$ ps -U 1000 |head -5
PID TTY TIME CMD
334 ? 00:01:50 chrome
2375 ? 00:00:02 gnome-keyring-d
2384 ? 00:00:05 gnome-session
2430 ? 00:00:00 ssh-agent

the first one uses my username, the second uses my UID... a 4 digit number.

If you have actual user names that are digits, that could be confusing
ps as it probably is expecting completely numeric strings to be UID
not usernames.

So, for example. lests say your sample name (that you provided) is
6545, and if you look through /etc/passwd, you see that hte UID for
user 6545 is actually 1002

if you ps -U 1002, you should get a process list for UID 1002, which
is the numeric for user name 6545. Does that makes sense?

So you could try something with the id command, like this:


bladernr@klaatu:~/development/trunks/checkbox$ ps -u `id -u bladernr` |head -5
PID TTY TIME CMD
334 ? 00:01:51 chrome
2375 ? 00:00:02 gnome-keyring-d
2384 ? 00:00:05 gnome-session
2430 ? 00:00:00 ssh-agent

that tells 'ps -u' to use the output of "id -u bladernr' ... the id
command returns the UID for username bladernr.


------------------------------------

To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)

<*> To change settings via email:
LINUX_Newbies-digest@yahoogroups.com
LINUX_Newbies-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
LINUX_Newbies-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

No comments:

Post a Comment