One significant difference I ran into (and did not see in an answer here), is that useradd --system
seems to imply --shell /bin/bash
, while adduser --system
implies --shell /usr/sbin/nologin
, which is what I wanted.
But I also wanted no home directory (which is the default with useradd
but not with adduser
), so I could either use useradd like this
useradd --system --shell /usr/sbin/nologin foo
(or /bin/false
is also popular for no shell)
Which leads to e.g. the following entry in /etc/passwd
foo:x:994:991::/home/foo:/usr/sbin/nologin
Or use adduser like this
adduser --system --no-create-home foo
Which leads to e.g. the following entry in /etc/passwd
foo:x:110:65534::/home/foo:/usr/sbin/nologin
Note that there are also very different automatic assignment of (G)UIDs. useradd
seems to pick them counting downwards from 999, while adduser
counts updwards from 100 for the UID and uses 65534 for the GUID (which seems to mean no group). In fact, useradd
also creates a group (see /etc/group
), while adduser
doesn't.
So for me, I will stick with adduser having learnt all those facts.
Source: Tested on Raspberry Pi OS (Debian Buster based).
useradd
is available on all Unix-like platform;adduser
is only for Debian and its derivatives.adduser
.useradd
is only available if the shadow package is installed.