Create new user and its dependencies:

$sudo useradd -s /bin/bash -m -c "user account description" new_username = create new_username with default bash shell (-s), default /home/new_username (-m) and a description/comment (-c).If you want to create home directory on a different location you need to use -d path/to/other/location as a command switch

$passwd username = set a login password for the username

$cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 14 | echo head ==> this will use urandom to generate a password “translating” from a-zA-Z0-9 characters and get the 14 chars of this psw and echo that. Will help generate random and complex passwords.

$groups = list all system existing groups

$usermod -aG userGroup1,userGroup2 username = add user to the a list of userGroups (-a "append", -G takes a list of comma-separated groups to assign user to)

$sudo usermod -aG adm cwagent = add user cwagent to group adm

$sudo adduser username groupname = To add a user to a group

$sudo mkhomedir_helper username = automatically creates username home directory in compliance with system policies

$id username = lists all groups this user is member of

=====

$sudo passwd -l username = To temporarily lock a user account

$sudo passwd -u username = To temporarily unlock a user account

$sudo passwd = change your own password

=====

$sudo chown -R root:root /home/username/

$sudo mkdir /home/archived_users/

$sudo mv /home/username /home/archived_users/ = change user folder ownership and archive it somewhere else

=====

$sudo addgroup groupname

$sudo delgroup groupname = To add or delete a personalized group

$sudo getent group groupname = check membership of groupname

=====

$sudo gpasswd -d user group = delete user from group

$sudo deluser username

$userdel username = delete user (then go and delete its home folder)

=====

$usermod -U username = unlock username account

$cat /etc/passwd = list local user accounts

$cut -d: -f1 /etc/passwd = list local user accounts (-d: says use “delimiter” : and -f1 says “display” field1 or column 1 onto the shell)

$grep username | /etc/passwd = check username groups and assigned shell

$grep username | /etc/shadow = check username encrypted password (if it has a ! at the beginning ==> account is locked)