All early versions of Ubuntu Desktops had a fantastic tool called as Users and Groups. It was available until Ubuntu 11.04 or perhaps until Ubuntu 11.10 (My memory is failing me). Since Ubuntu 12.04, this tool was dropped from the default list of Ubuntu packages. Sometimes I wonder what the guys in the Ubuntu development teams are thinking when they drop such superb tools, especially when they don’t have any other alternative. One such similar tool that has been dropped in Ubuntu’s Raring Ringtail is ‘Network Tools’. I will soon be posting a ‘Yah’ or a ‘Nay’ review on Raring Ringtail.
Coming back to ‘Users & Groups’ tool in Ubuntu – It is available in the repository and can be very easily installed from the terminal by running the following command.
sudo apt-get install gnome-system-tools
Once you have installed gnome-system-tools, you can find it in the dash as ‘Users & Groups’ and it will have the ‘Advanced Tab’ to make the necessary changes to the users. For making a user a part of a group, simply click on the check-box of the group the user will have to log out and log back in for the group associations to take effect. If you happen to delete a user, the home directory will not be deleted. You will have to manually delete the home directory of the user. Also, just by disabling a user, it will not stop the user from doing a remote ‘SSH’ connect with the machine, as keys have been exchanged. You have to ensure that even the key bindings have been removed.
With a command line, making any changes to the users and the groups is a bit tricky. But the following examples will help you know how you can quickly create users, add users to a group, delete users and difference between two similar looking commands in Ubuntu Linux
- Method 1 – sudo useradd kedar – This will add only the user. No home directory will be created, nor will the user be added in any group. There will be no password set for this user. You will have to set a password using ‘passwd’ command (sudo passwd kedar)
- Method 2 – sudo adduser kedar – This will add the user ‘kedar’ and will also create a group by the name ‘kedar’. This will also create a home directory for kedar. You will also be prompted to set a password for the user and enter other details for the user such as Full Name, Phone Number etc.
Method 2 is the recommended way of creating a user if the user is required to be a qualified user and not just a virtual user.
- You can add a user directly to a group by using the command ‘sudo adduser kedar www-data’. This will make kedar’s primary group as ‘www-data’ and will be able to run ‘Apache’ related processes
- Method 1 – sudo userdel -f kedar – This will delete the user and the home directory and mail spool. This will delete the user, even if the user is logged in. This command with ‘-f’ option is dangerous and can leave your system in a unstable condition. Group will not be deleted
- Method 2 – sudo deluser kedar – This will delete the user only and all other entries will have to be manually deleted – such as home directory, mail spool. If the user is logged in, you will not be able to delete the user. Group will not be deleted
Method 2 is the recommended way of deleting a user unless you are very sure of what you are doing
Adding an existing user to an existing group
- sudo usermod -a -G sudo kedar – This will add ‘kedar’ to ‘sudo’ group.
- sudo usermod -g sudo kedar – This will make ‘sudo’ group as a primary group of kedar. By default the primary group of kedar was ‘kedar’ when we created the user. By running this command we changed the primary group of kedar to ‘sudo’
One needs to be very careful when moving users to a group or removing users from a group. Permissions and privileges are managed through the groups and it is important you understand what you do while making changes to the groups.