List Users: cat /etc/passwd | grep “/home” |cut -d: -f1 && cat /etc/passwd | grep “/root” |cut -d: -f1
The Command ‘cat /etc/passwd | grep “/home” |cut -d: -f1’ on its own will list all the users found in the home directory. However root is not found in that directory so I added the additional statement to grep users in the /root directory, which will be root.
Add User: adduser <username> OR useradd <username>
Remove User: userdel <username>
Create User gGoup: groupadd <group name>
Add User to a Group: usermod -a -G <group name> <username>
Remove user:
- vi /etc/group
- Find the group and delete the user from it’s details
- Save File (Hit ESC then type :wq ENTER)
Delete Group: groupdel <group name>