由于某种阅读障碍的原因(或者睡眠不足),我输入了以下内容:
... 你知道嘛,我不小心删掉了一个用户!这以前从来没有发生过...
我该如何正确地恢复系统的用户呢?
deluser man
而不是更常见的
man deluser
... 你知道嘛,我不小心删掉了一个用户!这以前从来没有发生过...
我该如何正确地恢复系统的用户呢?
deluser man
而不是更常见的
man deluser
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