Ubuntu user management

Ubuntu user management

Ubuntu 15-05-2023 Saheb Sutradhar

Ubuntu user management


Topics : 

  • useradd
  • userdel
  • usermod
  • groupadd
  • groupdel

Files : 

  • /etc/passwd
  • /etc/group
  • /etc/shadow


How to create a user ? 

  • useradd user_name // this command will add many extra thing for example will create the group and home dir automatically. so if we don't want that we can have some option with the useradd command
  • useradd -g group_name -s /din/bash -c "Create demo user" -m -d /home/user_name  user_name


  • -g = group
  • -s = shell type
  • -c = comment
  • -m= means do you want home dir
  • -d= directory path

How to check the added users list ? 

less /etc/passwd  // will show the list of the user

How to delete user ?


  • userdel user_name // will not delete the home directory only will delete the user
  • userdel -r // will remove home directory
  • userdel -f // force delete if the user logged in

How to modify the user ?

Add user to a new group nut the default group will remain same

  • usermod -G group_name user_name     //-G means new group

Change the default group

  • usermod -g group_name user_name    //-g means default group

Other usermod options

  • -m -d  /home/new_home_folder home_folder // to move the home content to the new folder
  • -p  // to change the password or else we can use passwd command
  • -s // to change the shell type
  • -L -U // Lock or Unlock a user 


Lock and Unlock user account

//lock user use 1 or 2

  1. usermod -L username
  2. passwd -l username

//unlock user use 1 or 2

  1. usermod -U username
  2. passwd -u username

Set password for a user 

passwd user_name  // the it will ask you to enter the password 



Login to a user 

su - user_name

and now it will ask for the password


How to add group ?

groupadd group_name

check groups

less /etc/group


How to delete group ? 

groupdel group_name










Related Posts

Card image cap

How to install node JS on VPS (ubantu)

Ubuntu 15-05-2023 Saheb Sutradhar

How to install node JS on VPS (ubantu) ...