Creating and removing users
Creating users in Ubuntu can be done with one of either of two commands: adduser
and useradd
. This can be a little confusing at first, because both of these commands do the same thing (in different ways) and are named very similarly. I'll go over the useradd
command first and then I'll explain how adduser
differs. You may even prefer the latter, but we'll get to that in a moment.
First, here's an example of the useradd
command in action:
# useradd -d /home/jdoe -m jdoe
Note
As I mentioned in the front matter for this book, whenever I prefix commands with a pound symbol (#
), I'm instructing you to execute the command as root
. You can use the actual root
account for these types of commands or you can simply prefix the command with sudo
. In the latter case, the command would become:
# sudo useradd -d /home/jdoe -m jdoe
I won't remind you of this henceforth, so just keep in mind commands prefixed with #
need to be executed as root
or with the prefix sudo
.
In this example...