Skip to content

user

Add user to group

usermod -aG docker www-data
usermod -a -G sudo user

Create user

useradd --no-create-home --shell /bin/false node_exporter

Block user

usermod -L

Delete user

deluser <name>

Change user password

passwd <name>

Delete user

userdel -r <name>

List local users

cat /etc/passwd | grep "/home" |cut -d: -f1

User info

id <username>

List logged in users

who

List logged in users

finger

List logged in users

w

History of logins

last

History of failed logins

lastb

Chnage user password

passwd <username>

Add user to a group

usermod -a -G <group> <username>

Add new user

useradd <name>

Add new user (Debian)

adduser <name>

Add new service user

useradd -c -s /sbin/nologin <username>

Add new user and set password (for script)

adduser --no-create-home --gecos "" --disabled-password svc_testshell
chpasswd <<<"svc_testshell:P@ssword"

Last login attempts

last (/var/log/wtmp)
lastlog (/var/log/lastlog)
aulastlog (/var/log/audit/audit.log)

Last bad login attempts

lastb