Linux Tips 11: Ubuntu user management

One thing that I find myself doing a lot on my Linode server is adding and managing users. Sometimes I need to create accounts for clients, friends, or family. So some accounts are temporary and some are persistent. Nonetheless, they all require the use of the following few simply Ubuntu user management commands.

Ubuntu has four basic user management commands they are: adduser, deluser, passwd, and usermod.

Adduser is a script that presents common functions of useradd in a user friendly manner, which basically allows you to add a user to the system. To use it type (as root): adduser [newuser] and you will be prompted with basic user information such as name, password, etc. The user home directory will be created for you as well.

Deluser is the equivalent script to adduser. If called by it self it will simply delete a user's account, thus revoking their system access. If you want to completely remove a user you need to call: deluser --removehome --remove-all-files [new user] which will remove a user's home directory as well as all files that belongs to that user.

Passwd gives you much greater control over a user's password in terms of policy enforcement. You can lock an account passwd -l [newuser] and unlock it using passwd -u [newuser] You can also force the user to change their password immediately using passwd -e [newuser] or after a number of days passwd -c 7 -x 30 [newuser] (the user must change his/her password every 30 days, with a warning shown 7 days before).

Finally you can modify existing users' settings by using usermod. You can add them to new group usermod -a [newgroup] [newuser] or change their home directory usermod -d /home/newhome [newuser] or change their login name usermod -l [newnewuser] [newuser]

I have only gone through the most common use cases for myself with these Ubuntu user management functions, you can find more information as well as a list of all options from their man (manual) pages.


Chris said...

First thing I did with my Ubuntu server on linode is install webmin, makes this and many other tasks very very easy.

Paul Chiu said...

Thanks for the tip Chris. I will try it out.

Post a Comment