多个用户如何使用相同UID?

1856阅读 0评论2010-08-08 obsd178
分类:LINUX

转载本站文章请注明,作者:
本文连接

[jean@jeantoe ~]$ pwd
/home/test
[jean@jeantoe ~]$ touch abc
[jean@jeantoe ~]$ ll
total 0
-rw-rw-r-- 1 jean jean 0 2009-12-13 21:48 abc

实现方法

# vipw

test:*:500:500::/home/test:/bin/bash

原理解释

uid是不能重复,但是可以多个账户共用一个uid (不违反uid的唯一性)但是身份仅仅是第一个使用uid的那个账户身份

也可以使用useradd来完成。

useradd -o

-o, --non-unique
Allow the creation of a user account with a duplicate (non-unique)
UID.

如何揪出重复UID的用户。我在这里只考虑了有一组UID重复的情况,实际情况复杂时还要作一些调整。

[root@jeantoe mysqla]# grep `awk -F: '{print $3}' /etc/passwd | uniq -c | sort -r | sed '1p;d' | awk '{print $2}'` /etc/passwd

上一篇:如何创建和删除名称搞怪的文件?
下一篇:如何记录faillog?