User management in Linux


Introduction
In our database there are different users with different roles like in a LMS backend- there will be admin, principle, instructors, students and all these users will have different permissions in the same way linux distributions have 3 types of users namely Root user, System user and local user. All these users have different permissions and different roles in this understand how to manage them.
Root user :
It is the super admin of the system which have all the permissions and it is assigned with id 0. When we create a EC2 server login into root user is not allowed by default. which we can change from configuration file.
System user :
These are the system users like used by internal processing, running internal commands by our OS. User id range from 1 to 999.
local users :
These are the users created to mange the full system. User id range from 999 to 60,000(around).They handle tasks like security checks, deployment, package updation and all there tasks. By default AWS creates a local user with name ubuntu when you launch your ec2 server. You can see the example in below photo that there are multiple system users having id between 1-999 and there are 2 users that are local users having id 1000 and 1001 which are ubuntu and navneet respectively. You can view this in your system by running the command ‘sudo cat /etc/passwd’.
Why we don’t use Root user for every task ?
Because they they have the access to all files and files may be deleted accidently , No its not like that even a local user may have the all permissions which a root user holds. It is so because all the process and commands can be logged in a file we can view which user has executed what commands in short to track every execution.
Some essential command for users
‘whoami’ - run this command to view which user is currently logged in.
‘sudo cat /etc/passwd’ - it gives all the users (root, system and local).
‘sudo cat /etc/shadow’ it gives the password for all the users.
‘id <username> ‘ it guves the id of current user
Adding new user
To add new user first of all the current user should have the appropriate permissions assign like sudo permisiion which is necessary if you are creating some new user. If you have the permission you can create the user simple command which is ‘ sudo adduser <username>’ after running this you will be asked to enter some details of the user and user will be created. Later you can change the username by running ‘sudo usermod -l test_account test_user’ and hence name will change.
Reach out to me at - https://x.com/get2Navneet
Subscribe to my newsletter
Read articles from Navneet Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
