sudo passwd <username>
you may want to remove your keyring lock file as it doesn’t always update:
rm ~/.local/share/keyrings/login.keyring
From:
Create a new group
sudo addgroup groupname
Create a new user
sudo adduser username
create a new group by gid
groupadd -g <group-id> <groupname>
create a new user and group by groupid
MYUSER=ubuntu
MYGID=1000
MYUID=1000
groupadd -g ${MYGID} ${MYUSER}
useradd -u ${MYUID} -g ${MYGID} -p $(perl -e 'print crypt($ARGV[0], "password")' 'password') -G adm,sudo ${MYUSER} && mkdir /home/${MYUSER} && chown ${MYUSER}:${MYUSER} /home/${MYUSER}
another variant:
useradd -m my_new_username -p $(openssl passwd my_custom_password) && usermod -s /bin/bash my_new_username && usermod -aG sudo,other_groups,another_group my_new_username
Find groups associated with current user:
groups $USER
Add new user to new groups
sudo usermod -aG adm username
sudo usermod -aG sudo username
#...
modify list of groups user belongs to
unlike the last command(-aG
), -G
redefines rather than appends
sudo usermod -G usergroup,othergroup username
passwd [username]
remove user from group
sudo deluser username groupname
remove user completely
sudo deluser --remove-home username
more tips here
groupdel <groupname>
passwd --expire <username_here>
from here
Expire Account
Let the account expire to disallowing a user from logging in from any source including ssh:
# disallow peter from logging in
sudo usermod --expiredate 1 peter
This is how you can reenable that account:
# set expiration date of peter to Never
sudo usermod --expiredate "" peter
users:
cut -d: -f1 /etc/passwd
getent passwd
groups:
cut -d: -f1 /etc/group
getent group
users
who
whoami
list login dates / times, users, etc
last