Termainl User Commands

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:

  1. vi /etc/group
  2. Find the group and delete the user from it’s details
  3. Save File (Hit ESC then type :wq ENTER)


Delete Group: groupdel <group name>

Windows CMD Adding and Removing Users

To View Users: net user

To View Specific User: net user <username>

Add User: net user <username> <password> /add

Delete User: net user <username> /delete

Create a local user group (for network groups use ‘group’ instead of ‘localgroup’: net localgroup <group name> /add

Add user to local group: net localgroup <group name> <username> /add

Delete user from group: net localgroup <username> /delete

Delete local group: net localgroup <group name> /delete