Có một tiện ích được gọi là update-passwdcó vẻ như làm điều này một cách an toàn cho bạn:
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).
Trước tiên hãy kiểm tra mục hiện tại
$ getent passwd man
man:x:6:12:man:/var/cache/man:/bin/sh
Bây giờ hãy xóa nó đi
$ sudo deluser man
[sudo] password for steeldriver:
Removing user `man' ...
Warning: group `man' has no more members.
Done.
Kiểm tra xem nó thực sự đã biến mất
$ getent passwd man
$
Sau đó
$ sudo update-passwd --dry-run
Adding group "man" (12)
Adding user "man" (6)
Would commit 2 changes
OK, hãy làm đi
$ sudo update-passwd
2 changes have been made, rewriting files
Bây giờ xác nhận mục nhập tập tin mật khẩu được khôi phục
$ getent passwd man
man:*:6:12:man:/var/cache/man:/bin/sh