How to Create New User In CentOS? – POFTUT

How to Create New User In CentOS?


CentOS is enterprise level Linux distribution which is clone of the RedHat. User management like create, add, remove etc is important part of the daily Administration tasks. In this tutorial we will look how to add new user to the CentOS system.

List Current Users

Before creating new user we will list existing users. We can use different methods to list existing users but following is the most practical way to list existing users. We will cat user names with the cut command.

$ cut -f 1 -d : /etc/passwd
List Current Users
List Current Users

Add New User with useradd

Now we can add our new user. We have all ready checked the existing users but if we try to add existing user we will files. We will use useradd command by providing the user name. In this example the user name will be poftut .

$ useradd poftut

Add User To The Sudoers

Newly added user will have its own group and will not added to the other groups. Sudoers is a special mechanism which group name is wheel . Sudoers can run commands with administrator or root privileges. We can add newly created user to the Sudoers with usermod command. We will add user poftut to the wheel group which is Sudoers group.

$ usermod -aG wheel poftut

List Wheel Group or Sudoers Users

We can list current wheel group user members with the following command.

$ cat /etc/group
List Wheel Group or Sudoers Users
List Wheel Group or Sudoers Users

Change Shell To New User

We can practically change shell to the newly created user with the su command. In this example we will change to the user poftut like below.

$ su - poftut
Change Shell To New User
Change Shell To New User

LEARN MORE  Get-ADUser Powershell Command Tutorial To List Active Directory Users with Examples

Leave a Comment