Recipe for Adding Users to Linux

Posted 4 years, 3 months ago | Originally written on 5 Mar 2015

Create the user

me@home ~$ sudo adduser <username>

I like to use a default password that is easy to remember 'Password01' for first log in.

Add the user to any additional groups needed

me@home ~$ sudo adduser <username> <group>

Enforce change password on first login

me@home ~$ sudo chage -d 0 <username>

Enforce strong passwords

First, install the required library:

me@home ~$ sudo apt-get install

Next, modify the file /etc/pam.d/common-password by adding the following line at the end. It is space-separated.

password requisite ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 

where the parameters ucredit, lcredit, dcredit and ocredit specify whether upper-case, lower-case, different-case and other-characters are enforced.

Below is a more complex option including the maximum number of retries to change the password and a minimum length:

password requisite retry=3 minlen=10 difok=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 

Reset password

Enforcing strong password and limiting login attempts will invariably result in users getting locked out. You will therefore need to know how to reset accounts. It's easy.

me@home ~$ sudo passwd <username>

and you're done.


  1. Linux manual