Linux Basics: How to Add and Delete Shell Users on Ubuntu
Author: Daya Mukherjee
Last Edited: June 04, 2014
- 1.1 Overview
- 1.2 Addition and Deletion of Shell Users on Ubuntu Linux-An Introduction
- 1.3 How To Add a Shell User on Ubuntu Linux
- 1.4 How To Delete a Shell User on Ubuntu Linux
- 1.5 In a Nutshell
Ubuntu Linux is a popular end-to-end Linux system custom-built for desktop users. Being a highly proactive system, Ubuntu offers a distinct user interface, in addition to a wide array of tools for a largely fuss-free experience.
1.2 Addition and Deletion of Shell Users on Ubuntu Linux-An Introduction
Adding and removing shell users on a fresh Linux server remain amongst the most fundamental tasks every Linux user/system administrator must know. As a matter of fact, when a user creates a new server, they are simply given the default root account to begin with. While this arrangement entrusts users with phenomenal authority and tractability, the clout is highly prone to misuse, and may be manipulated in a destructive manner. Hence, to check abuse of authority, it is certainly advisable to add a supplementary unprivileged user for execution of common tasks. Lastly, system administrators must ensure the creation of additional accounts for miscellaneous system users so as to map a distinct account to each user.This tutorial offers a step-wise guide on the process of creating/deleting Shell user accounts on Ubuntu Linux.
1.3 How To Add a Shell User on Ubuntu LinuxIf you happen to be signed in as the root user, creating a new user is an absolute cinch. All you need to do is type the following command:
adduser newuserIt is, thus, fairly simple for root users to add new shell users on Ubuntu Linux. However, if you have signed in as a non-root user who has been assigned Sudo privileges, you may add a new user by typing:
sudo adduser newuser
In each of the above instances, the administrator is expected to endure the usual drill of answering a horde of questions, and subsequently following the process given below:
- Step 1: Assign and confirm a unique password for the new user.
- Step 2: Enter any additional information about the new user as per given fields.
Please note: Step 2 above is purely optional, and may be skipped by hitting <ENTER> if the administrator does not wish to supply information for the given fields.
- Step 3: Lastly, the system shall prompt you to confirm that the provided information is correct. All you need to do is Tye "y" to continue.
Voila! The new user is now alive and kicking, and may log in by simply inputting the password set up. You may continue from this point if you wish to assign administrative functionality access to the new user.
1.4 How to Delete a Shell User on Ubuntu LinuxIt is advisable to delete user accounts when not required/not in use. The user may be deleted in entirety using the following command:
sudo deluser newuserAn additional point worth mentioning here is that if you wish to delete the user's home directory once the user has been deleted, the following command shall do the trick for you:
deluser --remove-home newuserAlso, if you happen to run the above command as a non-root user (with Sudo privileges), you need to use the following command:
sudo deluser --remove-home newuserAn important point to note here is that if you had previously configured Sudo privileges for the user account you just deleted, you may remove the relevant line by typing the following command:
visudoIf, however, you are a a non-root user with Sudo privileges, you need to use the following commands to prevent any new user created using the same name from gaining accidental access to Sudo privileges:
root ALL=(ALL:ALL) ALL
newuser ALL=(ALL:ALL) ALL # DELETE THIS LINEThe above exercise shall essentially ensure a failsafe deletion of the user account, in addition to all the Sudo privileges associated with the given account, thus ensuring absolute peace of mind for system administrators.