Skip to main content

User

User​

Description
<group>Primary group, User must and only have 1 primary group. Can be view with getent passwd file (Usually stored in /etc/passwd)
<supplementary group>Additional groups, User may have multiple supplementary group. Can be view with getent group file (Usually stored in /etc/group)

Add user​

useradd <user> [-d <home directory>] [-g <group>] [-G <supplementary group>[,...]] [-s <shell>]
# Debian only
adduser <user>

Delete user​

userdel <user>
# Debian only
deluser <user>

Lock user​

passwd -l <user>

Unlock user​

passwd -u <user>

User database file​

Usually store in /etc/passwd

getent passwd

Password​

Password file​

Usually store in /etc/shadow

getent shadow

Change password​

passwd [<user>]

Delete password​

passwd -d <user>

Expire user password​

Force user to change password

passwd -e <user>

Set password expire day​

passwd -x <day> <user>

Group​

Change / Override user's primary group​

usermod -g <group> <user>

Change / Override user's supplementary groups​

usermod -G <group>[,...] <user>

Add user's supplementary groups​

usermod -aG <group>[,...] <user>