免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2178 | 回复: 7
打印 上一主题 下一主题

uid to user name [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-05 08:54 |只看该作者 |倒序浏览
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

论坛徽章:
0
2 [报告]
发表于 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

论坛徽章:
4
技术图书徽章
日期:2013-09-23 10:22:37狮子座
日期:2013-10-15 23:31:54卯兔
日期:2013-11-11 17:33:15金牛座
日期:2013-11-15 17:25:28
3 [报告]
发表于 2008-02-05 10:28 |只看该作者
我在solaris, redhat上试的ps -ef第一列都是username呀

你可以用ps -e -o "%U %a",第一列是USER

论坛徽章:
0
4 [报告]
发表于 2008-02-05 10:34 |只看该作者
ps -ef | awk '/$uid/{print $1}'

论坛徽章:
4
技术图书徽章
日期:2013-09-23 10:22:37狮子座
日期:2013-10-15 23:31:54卯兔
日期:2013-11-11 17:33:15金牛座
日期:2013-11-15 17:25:28
5 [报告]
发表于 2008-02-05 10:37 |只看该作者
solaris下ps -e -o "user args"

论坛徽章:
0
6 [报告]
发表于 2008-02-13 09:29 |只看该作者
如果ps出不来用户名的话可以去/etc/passwd文件找对应的用户名,你看看ps的man吧,应该是没有问题的。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
7 [报告]
发表于 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?

论坛徽章:
0
8 [报告]
发表于 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:~$
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP