34

For some dislexic reason (or haven't slept enough) I typed

deluser man

instead of the more common

man deluser

... as you can imagine, I just deleted man user! Never happened before...

How can I properly restore system's man user?

1
  • 5
    This is a perfect example why you don't use root for things that don't require root. Aug 14, 2015 at 15:16

1 Answer 1

33

There is a utility called update-passwd that appears to do this safely for you:

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).

First check the current entry

$ getent passwd man
man:x:6:12:man:/var/cache/man:/bin/sh

Now let's delete it

$ sudo deluser man
[sudo] password for steeldriver: 
Removing user `man' ...
Warning: group `man' has no more members.
Done.

Check it's really gone

$ getent passwd man
$ 

Then

$ sudo update-passwd --dry-run
Adding group "man" (12)
Adding user "man" (6)
Would commit 2 changes

OK let's do it

$ sudo update-passwd
2 changes have been made, rewriting files

Now confirm the restored password file entry

$ getent passwd man
man:*:6:12:man:/var/cache/man:/bin/sh
1
  • 2
    Excellent + upvoted. Please accept this instead of mine ;)
    – Rinzwind
    Aug 11, 2015 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.