passwd/shadow 或 group/gshadow 不匹配?

passwd/shadow 或 group/gshadow 不匹配?

我正在运行 RHEL 5。使用 GUI 系统>管理>用户和组时,出现错误:

无法读取用户数据库。此问题很可能是由于 /etc/passwd 和 /etc/shadow 或 /etc/group 和 /etc/gshadow 不匹配造成的。程序将立即退出。

一些研究表明,我需要分别使用 vipw 和 vigr 来查找这两组之间的不一致之处,我这样做了 - 为了方便起见,我将 [vipw | vigr] 中的每个复制到 excel 文件并执行 =exact(%1, %2)。没有不一致之处。

是什么赋予了?

// 编辑 //

sudo pwck -r 产生几个没有主目录的用户:

user adm: directory /var/adm does not exist
user news: directory /etc/news does not exist
user uucp: directory /var/spool/uucp does not exist
user gopher: directory /var/gopher does not exist
user ftp: directory /var/ftp does not exist
user pcap: directory /var/arpwatch does not exist
user sabayon: directory /home/sabayon does not exist
user oprofile: directory /home/oprofile does not exist
user avahi-autoipd: directory /var/lib/avahi-autoipd does not exist

我认为这对于服务帐户来说是正常的。

但是,sudo grpck -r 会产生一些有趣的输出(已清理):

no matching group file entry in /etc/gshadow
add group 'g0' in /etc/gshadow ?No
'u1' is a member of the 'g1' group in /etc/group but not in /etc/gshadow
'u2' is a member of the 'g1' group in /etc/group but not in /etc/gshadow
'u3' is a member of the 'g1' group in /etc/group but not in /etc/gshadow
no matching group file entry in /etc/group
delete line 'users:::'? No
no matching group file entry in /etc/group
delete line 'u4:!::'? No
no matching group file entry in /etc/group
delete line 'u1:!::'? No
no matching group file entry in /etc/group
delete line 'u2:!::'? No
no matching group file entry in /etc/group
delete line 'u3:!::'? No
no matching group file entry in /etc/group
delete line 'u5:!::'? No
no matching group file entry in /etc/group
delete line 'u6:!::'? No
no matching group file entry in /etc/group
delete line 'u7:!::'? No
grpck: no changes

所以,显然我们发现了一些问题。在我看来,自动修复在某些情况下可能会造成破坏。

答案1

为什么要使用 Excel?

cut -d: -f1 /etc/passwd | sort > p.out
sudo cut -d: -f1 /etc/shadow | sort > s.out
diff p.out s.out
rm p.out s.out

或者在 Bash 中:

diff <(cut -d: -f1 /etc/passwd | sort) <(sudo cut -d: -f1 /etc/shadow | sort)

/etc/group您可以对和执行相同操作/etc/gshadow

您需要GUI System>Administration>Users and Groups以提升的权限运行。它是否要求您输入密码?

相关内容