LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-17-2010, 01:45 AM   #1
narendra1310
Member
 
Registered: May 2008
Posts: 41

Rep: Reputation: 15
Thumbs up How to get userName in place of UID in the process check ?


Hi all,

I add a user in my linux machine using the command 'useradd' as shown below.
# /usr/sbin/useradd -c "Non Root User" -d "/home/testUser" -g root testUser

"/etc/passwd" file shows that user created with uid '517'
cat /etc/passwd
ot:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
testUser:x:517:0:Non Root User:/home/testUser:/bin/bash

Then i executed my application 'myApp' with 'testUser' using command as shown below:
# cd /home/testUser/MY-APPLICATION
# su -l testUser -c "./bin/myApp"

But when I check the process with 'ps' command it shows 'myApp' with uid '517' rather than user name 'testUser'.
# ps aux |grep myApp
517 4299 13.1 0.3 131616 6644 ? Sl 11:46 2:44 ./bin/myApp

please help me, how to get user name in the process instead of uid.

regards
Naren
 
Old 04-17-2010, 02:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
Use a 'ps' alias that uses the "-eo user" arg as in 'ps ax -eo user,pid,cmd'. You should note that working with numerical Ids is faster as no resolving is needed (also: 'ls -n', 'netstat -n', 'lsof -Pn').
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Files have owner as uid number rather than username prollocks Red Hat 4 11-18-2009 07:08 PM
ps -ef shows UID rather than username bazzagazza Linux - Newbie 5 05-10-2007 04:16 AM
Obtaining uid from username JPrieSL Programming 4 04-20-2007 08:31 AM
OpenLdap PAM UID vs Username Authentication zerovice Linux - Enterprise 0 12-05-2005 09:38 PM
Getting uid and/or username of logged in user rjstephens Programming 5 09-23-2004 05:02 PM


All times are GMT -5. The time now is 05:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration