How To Add/Remove New User In Linux/Unix
This post was last updated on September 14th, 2019 at 07:22 am
In this article, we will learn to add or remove users and giving them required permissions in Linux or Unix. As these operating systems are multi-user many users can have accounts on a single OS and can use resources simultaneously at a time. So It is necessary to manage all the users or user groups. A system administrator manages all these user or user groups and their rights. We will use the command-line user interface to create, delete and grant the root privileges to the created user.
Creating a new user
If currently you are logged in as root user or have superuser privileges. You can directly execute the command given below in your terminal
Otherwise, if you do not have root access you can use the command below
It will ask to enter the new Unix password for newuser, enter it. And again retype when it asks. Then it will ask other details about the user which are optional you can skip by hitting enter. Finally, confirm that the information provided is correct. Press y and then enter. Now newuser has been created.
Grant sudo privileges to the new user
Sometimes we need to execute commands which require root access like installing or removing a package. By default created users will not have that access. So we will have to provide superuser privileges to the new user for that we will add created user to sudo group. When we create a new user it automatically gets added to its own group. To check the group of a user we should use groups command as given below-
To get all groups in the system use the following command in your terminal.
We will now add the created user to sudo group. To add a new user into a group we should use
usermod command. Syntax of which is given below:
here we will add a new user with name newuser to sudo group. Note that newuser is now added in two groups that are newuser its own group and sudo.
If you no longer need that user account you can delete it by using the following command
It will not delete user data you can delete it later by using following command
Now I think you should have a basic understanding of creation, removal of user and adding that user into a group. If you have any query write us in the comments below.
You might also like
Contents1 What Is init?2 What is SystemV (SysV)?2.1 Runlevels –2.2 Mostly used SysV service commands are –3 What is Systemd in modern Linux system?3.1 What is systemctl? –3.2 Some commonly
This post was last updated on May 2nd, 2020 at 10:08 amDD command is used to create a bootable disk from an existing image as it clones data from one