Create and Manage Linux Users

I’ve had to create a user on my linux server a number of times in the last few months and every time I have to look up how to do it.

To create a user for your linux server…

$ useradd <username>

… without alias, on mine anyway…

$ /usr/sbin/useradd

You will probably need to use sudo or to switch to root user $ su, unless you’re ssh’ing in under root. Word to the wise: “Don’t!” Really for security you should disable root access via ssh and allow switch user or su.

Add/Change password:

$ passwd <username>

Specify a home directory for user:

$ usermod -d <path/to/directory> <username>

Or you can add the home directory when creating the user:

$ useradd <username> -d <path/to/directory>

Nice note: this will create the directory if it isn’t already created.