Thursday, July 27, 2023

Manage Users and Groups(Part-8)

  In Part-7 of the Learning Linux blog series, we learned how to configure and manage basic networking in Linux Systems.

In part 8, We will construct basic commands to manage users and groups in the Linux Operating System.

  • Create, delete, and modify local user accounts
    • Create UserId: 
      • sudo useradd john (create a new user john with primary group as same john and assign home directory path, /bin/bash shell environment), 
      • sudo passwd john(set new password), 
      • sudo userdel john(delete user john without removing home/malspool, --remove should be used if you want to remove home dir), 
      • sudo useradd --shell /bin/othershell --home-dir /home/otherdir john, 
      • sudo useradd -s /bin/othershell john(just changing the default shell), 
      • sudo useradd --system systemacc(Add service/system account)
    • Local user accounts: 
      • cat /etc/passwd(this file store the userid details), 
      • sudo id (list the users who are signed-in), 
      • whoami(To see your current login userid detail), 
    • Modify users: 
      • sudo usermod --home /home/otherdir --move-home john (Modify the home dir),
      • sudo usermod --login jane john(Change username),
      • sudo usermod --shell /bin/othershell jane(change the default shell), 
      • sudo usermod -lock jane(lock/disable the account without deleting it), 
      • sudo usermod -unlock jane(unlock the account), 
      • sudo usermod --expiredate 2021-12-10(Set expire date for account), 
      • sudo chage --lastday 0 jane(set account's password to expire immediately or put -1 to un-expire it, --maxdays for set password expire days, -1 value means neverexpire),
      • sudo chage --list(To see the accounts expiration), 
    • Delete User/grp: 
      • sudo userdel -r jane, sudo groupdel john
  • Create, delete, and modify local groups and group memberships
    • Local group and membership: 
      • sudo gpasswd --add john developers(add john on developers group as secondary/supplementary), 
      • groups john(list the group membership for user john), 
      • sudo gpasswd --delete john developers(remove user from group), 
      • sudo usermod -gid developers john(Change the primary group for user john to developers),  
    • Modify group: 
      • sudo groupmod --new-name programmers developers(rename group),  
      • sudo groupdel programmers(Delete Group), 
  • Manage access to the root account
      • sudo --login or sudo -i(loging as root user if you're a sudo user), 
      • su --login or su -l(If you know the root password and does not member pf sudo), 
      • sudo passwd --unlock root(unlock the root account if it was locke, --lock to lock it again but ssh key login will still work),
  • Configure PAM(Pluggable Authentication Module)
    • man pam(list the pam modules and their help documentation), man pam.conf(To see the pam configuration help doc),
      • ls /etc/pam.d/ (list the pam related conf files), 

Note: Use the Linux manual using "man <command)" or "command --help" to access the command documentation for more detail. 

#> echo "Thank you :)"