Chinaunix

标题: uid to user name [打印本页]

作者: dawncaller    时间: 2008-02-05 08:54
标题: uid to user name
want to get the user name from uid for example uid=1667

id -un 1667, it gives no such user, which 1667 is my account, any idea why? thanx
作者: dawncaller    时间: 2008-02-05 09:04
actually i need ps -ef to check if something is run by one user, and i need the username, eg, alex.g, but ps -ef gives the uid at the first column
作者: nbrr    时间: 2008-02-05 10:28
我在solaris, redhat上试的ps -ef第一列都是username呀

你可以用ps -e -o "%U %a",第一列是USER
作者: 7717060    时间: 2008-02-05 10:34
ps -ef | awk '/$uid/{print $1}'
作者: nbrr    时间: 2008-02-05 10:37
solaris下ps -e -o "user args"
作者: walkerxk    时间: 2008-02-13 09:29
如果ps出不来用户名的话可以去/etc/passwd文件找对应的用户名,你看看ps的man吧,应该是没有问题的。
作者: 網中人    时间: 2008-02-14 02:50
man id
SYNOPSIS
       id [OPTION]... [USERNAME]


so, the id command eats USERNAME only as it's argument, not the UID instead.
clear?
作者: chaos_eternal    时间: 2008-02-14 07:46
chaos@felucia:~$ getent passwd chaos
chaos:1000:1000:chaos,,,:/home/chaos:/bin/bash
chaos@felucia:~$ getent passwd 1000
chaos:1000:1000:chaos,,,:/home/chaos:/bin/bash
chaos@felucia:~$ getent passwd 1002
noshellt:1002:100::/home/noshellt:/bin/true
chaos@felucia:~$ getent passwd 1003
chaos@felucia:~$




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2