Use the --gecos
option to skip the chfn
interactive part.
adduser --disabled-password --gecos "" username
It's all in the man page. Not the most obvious formulation tho.
--gecos GECOS
Set the gecos field for the new entry generated. adduser will
not ask for finger information if this option is given.
The GECOS field is a comma separated list as such: Full name,Room number,Work phone,Home phone
, despite that man page mentions finger information
Details - Wikipedia
Hope this helps you.
Update: for more recent (or upcoming) versions of adduser
, the --gecos
option is replaced by --comment
.
--comment comment
Set the comment field for the new entry generated. adduser will
not ask for the information if this option is given. This field
is also known under the name GECOS field and contains informa‐
tion that is used by the finger command. This used to be the
--gecos option, which is deprecated and will be removed after
Debian bookworm. Valid Modes: adduser, adduser --system.
adduser
idempotent? (if the user already exists, keep silent instead of prompting an error) – Ragtime Feb 21 '23 at 09:36getent passwd <username>
before invokingadduser
/useradd
. – Zoke Feb 22 '23 at 03:48