I am trying to add a new user to the system. I am confused though which command to run:
Despite what the manpage says for
userdel, I always use the low level back-end binaries:
The front-end scripts are interactive and meant to be user friendly, but do the same things. It is really a matter of personal preference.
In terms of practical differences:
groupadd have similar options to the commands
groupmod, and there are no front-end scripts for these commands (i.e. no
modgroup front-end scripts) so it is more consistent to use similar commands for account maintenance.
There are different config files for the default settings, like user IDs, shells, login groups, etc. So make sure you know which one you are editing to change the settings.
The front-end scripts "protect" you from entering stupid names, unless you supply the
--force-badname option. For instance, usernames or group names that contain special characters, or that begin with a number. This is something that is unlikely to be done accidentally, so there is no need for the "protection."
The front-end scripts also "protect" you from deleting the root account, unless you use the
--force option. Why anyone would be trying to use this, I don't know. It's also worth pointing out that you can't remove a user account if there is a running processes under it, and there is always processes running as root, so this should fail anyway.
(I've never had the courage to try, however.)
Only the front-end script adduser has an option to encrypt the home directory.
There are some things that the friendly scripts cannot do, however, and you would need to resort to the binary commands, though these are things you would normally not need to do:
useradd can override the default value of the skeleton home directory, without the need to edit the config file, or create a new config file. See the
useradd can prevent adding the newly created user to the lastlog database, with the
useradd and groupadd can create accounts with non-unique UIDs or GIDs, respectively, using the
-ooption. The scripts do not provide this capability.
useradd can create a new user with a selinux mapping, if selinux is enabled on the system, with the
-Zoption. This, however, can also be done with other commands once the account has been created, like
finally, and perhaps most importantly, only the binary commands have the ability to operate on alternate systems under an alternative root directory, like
/snap/core, using the