Creating users and groups in Linux

Note: To try out the examples in this document, you would need root access.

To create a new user you use the adduser command. To add a user by called linuxjunky:

$ adduser linuxjunky

If you get a command not found error

$ /usr/sbin/adduser linuxjunky

To assign a password to your new user

$  passwd linuxuser

To grant ownership of a file to the new user

$ chown linuxjunky filename

To change grant ownership of a directory to the new user

$ chown -R linuxjunky myfolder/

Suppose you have three users (john, jim, jake) each of whom require ownership of a directory. For example the web/ directory. The best way to do this would be to create a group. Make them members of this group and grant ownership to this group.

To create a group:

$ groupadd webmanagers


$ /usr/sbin/groupadd webmanagers

This would add a line such as the following to the end of your /etc/group


Use a text editor such as vi to change this line the following


To grant ownership to a file

chgrp webmanagers index.html

To grant ownership to a directory

chgrp -Rv webmanagers web/