Skip to content

Users and groups

Linux

Create user

useradd  -s /bin/bash [user]
# 
adduser --shell /bin/false --ingroup {group} {new_login}

Delete user

userdel [user]
# -r = remove home folder - NEVER DO IT !!!
# Were next cases:
#   1) /var/www stored in user home directory
#   2) /home/user has content of working www site 

Lock/Unlock user

# Lock user
usermod -L [user]
passwd -l [user]

# Unlock user
usermod -U [user]
passwd -u [user]

Add/Remove users to group

# Add existing user to existing group
usermod -aG [group] [user]
# ... or
gpasswd -a [user] [group]

# Remove user from group
usermod -rG [group] [user]
# ... or
gpasswd -d [user] [group]

Change shell for user

chsh -s [shell] [user]
# example
chsh -s /bin/bash mark

FreeBSD

Remove user

pw userdel 

Block/Unblock user

pw lock
pw unlock 

Groups

# add
pw groupmod [group] -m [user]
# remove 
pw groupmod [group] -d [user]

Change shell for user

pw usermod -s /bin/tcsh