To view current users and additional information about the users, you can view the following file using the cat command:

cat /etc/passwd

This will show a list of current users, 

for e.g root:x:0:0:root:/root:/bin/bash, information is separated by a ":"

and it tells us the following:

username:pswd:userID:groupID:home Dir:Default shell

 

Creating a new user:

sudo adduser name

Deleting a new user:

sudo userdel username

Giving sudo access to the new user:

Let's say we had a new user called student, and the current user is vagrant, then we would follow the following steps:

  • sudo cp /etc/sudoers.d/vagrant /etc/sudoers.d/student
  • sudo nano /etc/sudoers.d/student
  • and change the first line from vagrant to student
  • # CLOUD_IMG: This file was created/modified by the Cloud #Image build process
  • student ALL=(ALL) NOPASSWD:ALL
  •  

Prompting the new user to change their new password on their next login:

sudo passwd -e username