For some dislexic reason (or haven't slept enough) I typed
instead of the more common
... as you can imagine, I just deleted man user! Never happened before...
How can I properly restore system's man user?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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 $
$ 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