Latest Blogs

HOW TO CREATE & REMOVE USERS AND GROUPS IN LINUX OS – DEEP ANALYSIS

 Every user has its own directory and personal files. Every user has unique identification number user cannot read, write and delete the file without permission. In Linux, operating system all users files are located in /etc/passwd file.

 

What is /etc/passwd file?

/etc/passwd configuration file exist in operating system , it consist all user related information with combined information such as user id, username, user home or default directory, group information and shell information.

How to create users in Linux?

First of all, you must login in operating system terminal. By right clicking  search for “Open Terminal” option.

Or

You must open command line interface before apply the command. Alternatively, you can find the option under the accessories category.  




How to add user in Linux?

Apply the useradd command in the open terminal interface.

Syntax

#useradd   <username>

Press enter to proceed

How to Setup a password for newly created user?

 Syntax

#passwd   <username>

Press enter to proceed


 

Remember, root is administrator in linux and root ID is always assigned 0. Even you can’t change it or assign it.

Apart from this there are two types of users exists System user and normal users.

System User ID – 1-999

Normal User – 500 onwards

 

How to open the /etc/passwd configuration file?

Open the terminal and apply the following command:

# vi /etc/passwd

Press enter to proceed


Now, it is required to check the all content in existing /etc/passwd configuration file. As above screenshot you can simply open the file. After opening passwd configuration file, it shows some information.


 A lot of information exists in above configuration file. It is required to understand in simple way. Here it is:



Now, it is better and shows each entry is clear and makes sense. First section represents the user name information which user name is exist in operating system.

Next section represent the pointer password file where it is located all users’ password information in encrypted form. In linux, /etc/shadows is password file and store all the files. “x” is pointer or reference file for shadow file.

How to open /etc/shadow file?

In terminal apply the command:

# vi /etc/shadow

Press enter to proceed


Above figure shows the content of shadow file. It stores all user password information in encrypted form. Well, now we get back to our main topic. It is just for your knowledge.

Another section represents the user id. As discussed earlier root user always allocated “0” Id in operating system. In addition, another “0” value refer the group id information.

User reference section is also be there represent the user information.

Which directory location user access when it is logged in OS?

/etc/passwd file show the another section /root, it shows location of user. So, root user always accessed /root directory when it is logged in the operating system. In normal user, it access under the /home directory.

In which shell linux user accessed?

Last section in /etc/passwd is shell information. /bin/bash is default shell path exist in operating system. For more information about shells please read our shell blog to understand different type of shells exists in OS.

How to remove user in linux?

To remove user in linux, it is easy process. Simply type “userdel’ command and mentioned the specific user name information.

Syntax:

# userdel <username>

Press enter to proceed 


How to add group in linux OS?

It is same procedure to create group in linux operating system. By simply apply the below command in the terminal section:


How to delete the group in linux?

Open the terminal option and type “group del” command in command line interface.

Syntax:

# groupdel <group name>

Press enter to proceed.



Final conclusion in this blog is user and groups are core part of operating system to access any type of applications. Adding a new user or group in linux must need to know about it. A configuration file plays important part in linux operating system. /etc/passwd is master file contains important information related to users and groups. As we deeply analyzed /etc/passwd and /etc/shadow file represents user connections. Configurations files is also represents user id, directory and shell information which is also informative and we should know about it. Moreover, we learned to create or removal of users and groups in operating system as well. If you want more information required, you can send us queries.


No comments