Answers:
有一个名为的实用程序update-passwd
可以为您安全地执行此操作:
NAME
update-passwd - safely update /etc/passwd, /etc/shadow and /etc/group
SYNOPSIS
update-passwd [options]
DESCRIPTION
update-passwd handles updates of /etc/passwd, /etc/shadow and
/etc/group on running Debian systems. It compares the current files to
master copies, distributed in the base-passwd package, and updates all
entries in the global system range (that is, 0–99).
首先检查当前条目
$ getent passwd man
man:x:6:12:man:/var/cache/man:/bin/sh
现在让我们删除它
$ sudo deluser man
[sudo] password for steeldriver:
Removing user `man' ...
Warning: group `man' has no more members.
Done.
检查它真的消失了
$ getent passwd man
$
然后
$ sudo update-passwd --dry-run
Adding group "man" (12)
Adding user "man" (6)
Would commit 2 changes
好的,让我们一起做
$ sudo update-passwd
2 changes have been made, rewriting files
现在确认还原的密码文件条目
$ getent passwd man
man:*:6:12:man:/var/cache/man:/bin/sh