恢复man用户

Modified on: Sun, 10 Jun 2018 00:57:53 +0800

由于某种复杂的原因(或者睡眠不足),我输入了

deluser man

而不是更常见的

man deluser

......你可以想象,我刚刚删除了man用户!从未发生过...

如何正确恢复系统的man用户?

作者:Marc

最佳答案

有一个名为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).

首先检查当前条目

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

相关问答

添加新评论