There are two ways to manage users and groups in Ubuntu:
1. Graphical -> The simplest way.
2. Command line text -> More technical but more powerful, several things can be done at once.
THE GRAPHICAL WAY IN UBUNTU
With Ubuntu 4.12, graphical user interface is now called “user accounts” and some options have been removed. Basically, users can only create/delete users, manage account type, language, password and startup options.
If options from earlier versions are needed, the “gnome-system-tools” package must be installed. This can be achieved by means of the software center or by typing the following in the command line:
sudo apt-get install gnome-system-tools
This package contains the following applications:
Users and groups -> This is the former “users and groups” tool.
Date and time
Shares (NFS and Samba)
After running the install command, a shortcut called “Users and Groups” can be accessed from the Dash (Super key or by pressing the first “Start” launcher in Unity bar).
Users and Groups
1. To add a new user:
Click the “Unlock” button and enter the root password.
Click + Add User and the User Accounts Editor window opens.
The most important fields in the “Account” tab are:
User name. Do not use spaces or ASCII characters
Actual name. This is optional
Profile: Choose between Administrator, Desktop User, and Unprivileged User (this creates a user with the default privileges, although it can be subsequently modified).
Password: Can be manually set (enter it 2 times) or let Ubuntu automatically generate it.
“Contact Information” tab:
The location of the office and telephones can be entered here. This is optional.
“User Privileges” tab:
You can grant or deny privileges to the new user, such as access to audio devices.
The home folder directory, the shell, the main group and user ID are set automatically depending on the selected profile, so they should not be modified.
2. To modify an existing user:
Select the user to edit and click the Properties button. A window similar to the one used to add new users, allows for modification.
3. To delete an existing user:
Select the user or users to be deleted and press the Delete button on the Users tab. Due to the importance of this data, an confirmation window will be shown for each user to be deleted.
For security reasons, the home directory of the deleted users will not be removed.
4. To add a new group:
Click on “Manage Groups” and then click the “Add Group” button, a new window pops up, requesting for data of the new group:
Name of the group.
ID of the group.
Optionally, you can specify which users belong to this group.
5. To modify an existing group:
Click on “Manage Users”, select the group and click the Properties button. A window similar to “Add group” pops up, and data can be modified from there.
6. To delete an existing group:
Click on “Manage Users”, select the group and press the Delete button. Due to the importance of this data, you will be prompted for each group you want to delete.
MODE TEXT WITH THE TERMINAL
To manage users, the sudo command must be issued. These are the task specific commands:
Adding Users And Groups
To add a user:
sudo adduser username
The system will request additional information about the user. By default, it creates a group with the username which will be the default group for that user. This behavior is configured in /etc /adduser.conf.
To add a user to the system by setting “users” as their primary group:
sudo adduser – ingroup users username
To see the manual pages for the adduser command.
sudo adduser man
Groups are useful when the number of users is large and heterogeneous. Groups simplify administration. Creation of groups is done with the addgroup command:
sudo addgroup groupname
To add a new or existing user to an existing group:
sudo adduser username groupname
2. Remove users and groups
userdel and groupdel are used respectively to remove users and groups. For example: To delete the user john:
sudo userdel john
If the -r option is also indicated the system deletes the user’s home directory and all its contents:
sudo userdel-r john
To delete the group teachers:
sudo groupdel teachers
3. Modify users and groups
To modify users and groups, the usermod and groupmod are used.
Change the user’s home directory for john to /home/faculty/john. Also, use the -m option to move the content from the old directory to a new location.
sudo usermod -d /home/profs/john –m
To change the initial user group john to be teachers.
sudo usermod -g teachers john
To change the username john to the new name is george.
sudo usermod -l george john
To change the name of the teachers group to students.
sudo groupmod -n student teachers