User Management in Linux – Complete Notes for Beginners

                             

                                             USER MANAGEMENT


• Types of USER

1.Root user ( UID = 0) (SHELL= Login shell /bin/bash)

 2. Local user ( UID = 1000 TO 6000) (SHELL=Login shell)

 3. System user ( UID = 1 TO 999) (SHELL= Nologin shell /sbin/nologin)

 • Type of GROUPS

 1. Primary group 

2. Secondary group

 /etc/passwd = A file that contains “user” information 

/etc/group = A file that contains “group” information 

                                                COMMANDS 

1. useradd = crate a new user useradd username 

                     Exmaple = useradd admin 

2. groupadd = create a new group groupadd groupname 

                        exmaple = groupadd parul 

3. id = provide user details id username 

                      Example = id admin 

4. userdel = deleting a user userdel username 

                     Example = userdel admin 

5. groupdel = deleting a group groupdel groupname 

                    Example = groupdel parul 

6. userdel –r = deleting a user from their home director and mail director 

                        userdel –r username

                         Example = userdel –r admin 

7. useradd username –c “comment” = addind a comment to a user 

                    Example = useradd admin –c “important user” 

8. useradd –g = create a primary group 

                  Exampe = useradd tv –g mobile ( tv is the primary group of mobile) 

9. useradd –G = adding a user to a secondary group 

                Example = useradd username –G groupnam 

10. useradd –M = the user will be created but will not be created in the “home directory” 

                             Example = useradd –M username 

11. useradd –s = give shell to user 

                              Example = useradd –s /sbin/nologin username 

12. useradd –u = give UID to user 

                            Example = useradd username –u 2000 

13. passwd = set password in user 

                         Example = passwd username 

14. Usermod = to modify the user ( Making changes to a user after it has been created ) 

15. usermod –s = changing the user’s shell 

                        Example = usermod username –s /bin/bash 

16. usermod –aG = add multiple secondary group 

                        Example = usermod username –aG groupnam 

17. usermod –g = change primary group 

                      Example = usermod username –g groupname 

18. chage = password change policy 

                 chage –l = information about user’s password expire, inactive days, account expire 

                 Example = chage username 

 chage –M 30 –m 19 username ( change min. And max. Days password ) 

 Chage –E 2025-12-31 username ( set account expire date) 



                  



           


                          useradd –g & useradd –G


                                  



                          useradd –s command 
          

            

       


           
  






                           chage command

                                   chage –l command 




                      chage –E command





               /etc/group = 4 fileds in this file
 

When a user is created, changes are made in these 7 files or than the user is added to them:
                                           

                 
                 

Comments

Popular posts from this blog

DevOps Roadmap 2026 – Your Complete Beginner-to-Expert Guide

What is Public Subnet in AWS? Step-by-Step Explanation with Example