Files Generated When we create a user in Linux

Hello, everyone In this Article we are going to learn what are the files generates when we create the user in Linux in a very simple and easy step-by-step approach.

Yellow Fishing Boat Blog Banner 58 1

What is the need of user in linux ?

Suppose that we have one server that is running for 24X7 hours and that server is a very critical server by default there is a root user that is already created on the server.

Now there are multiple employees is working on the Linux server 24X7. We cannot give everyone as root user power because if any employee will do any mistake on the Linux server then logs are generated by root user only. We cannot able to identify which user done the mistake.

After making the users in the Linux server we can able to identify the logs of individual users and we can easily find which user is doing what tasks.

There are three types of users that are available in Linux

1. Super user – Root is super user this has full power on Linux server

2. System user – These users are helping to run the services in Linux. Whenever we install any package in Linux these users created by default for Example DHCP / Samba / Apache / NFS

3. Normal user – These users are created by the root user for example harry , natasha etc.

When ever we make users in linux UID and GID is created by default

  • Root user UID (User Id) – 0
  • Root user GID (Group Id) -0
  • System user UID (User Id) – 1 – 999 in RHEL 7
  • System user UID (User Id) – 1 – 499 till RHEL 6
  • System user GID (Group Id) – 1 -999 in RHEL 7
  • System user GID (Group Id) – 1 -499 till RHEL 6
  • Normal user UID (User Id) – 1000-60000 (we can increase the range by editing the /etc/login.defs)
  • Normal user GID(Group Id) – 1000-60000 (we can increase the range by editing the /etc/login.defs)

The Linux System can be loggedin only by root user or Normal user.

If we login as root user then command prompt will appear like this. There is # symbol in the last of the command prompt

Let’s see what we get in the Command Prompt if we are logged in as root user

Screenshot 12 24

If we login as a Normal user then command prompt will appear like this. There will be $ symbol in the last of the command prompt

Let’s see what we get in the Command Prompt if we are logged in as a Normal user

Screenshot 13 22

1 – /etc/passwd file – We are taking the user1 example here. There are total 7 fields in this file

Screenshot 1 38

1 – Name Of the user – user1

2 –  x – Password pointer file to /etc/shadow

3 – UID (User Id ) –1001

4. GID (Group Id ) – 1001

5 – Comment for the user

6 – /home/devopstut – Home directory for the devopstut user

7 – /bin/bash – Default login terminal of the user

2 – /etc/shadow – We are taking the user1 example here. There are total 9 fields in this file.

Screenshot 3 37

1 .Name of the user ie. devopstut

2. The password of the user in the encrypted format

3. Number Of days since Linux kernel is built till now. For example, this is the total number of days since 1st January 1970 till now.

4. Minimum Number of days for the expiration of the password

5. Maximium number of days for the expiration of password

6. Number of days before give warning to change the password.

7. Field is reserve for future use

8. Field is reserve for future use

9. Field is reserve for future use

3 – /etc/group – Here we have 4 fields

Screenshot 5 36

1 Name of the group ie. tutdevops

2. The password of the group pointing to /etc/gshadow file

3. Group Id ( GID ) eg – 1002

4. Member of the group – ex tutdevops is the member of the group harry

4 –/etc/gshadow – Here we have total of 4 fields

Screenshot 6 36

1 Name of the group

2. Password attached to group in encrypted form

3. Who is the Administrator of the group

4. Members attached to group

5 – /var/mail – This is the directory where we can store the mail messages of the user’s same name of mail files that are created with the name of the users. Here we have taken example for devopstut user currently we don’t have any mail that is why this is showing blank .

var mail

Conclusion

If you want to learn Linux in the most simple language then please click on this link.

This is the complete knowledge of what are the files that generate when we create a user in the Linux kernel if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on DevOps Articles.

Leave a Comment