https://www.godaddy.com/help/remove-a-linux-user-19158
cat /etc/passwd
Each row represents a user and the fields separated by the colon (:) has the following meaning:
- User name
- Password, x means that a password is set for the user
- User ID (UID)
- User's group ID (GID)
- Full name, room number, phone number etc (optional)
- Home directory of the user
- Default login shell for the user
grep -E '^UID_MIN|^UID_MAX' /etc/login.defs
root@learnubuntu:~# grep -E '^UID_MIN|^UID_MAX' /etc/login.defs
UID_MIN 1000
UID_MAX 60000
Use the cut command to use the : as column separator and then display the first column.
cat /etc/passwd | cut -d: -f1
You can do the same with the awk command:
cat /etc/passwd | awk -F: '{print $1}'
Use getent command to list users
getent passwd
You can list only the regular users the same way:
getent passwd | cut -d: -f1
What if you just want to know if a user exists or not?
getent passwd : grep user_name
List normal users only (for scripting)
eval getent passwd {$(awk '/^UID_MIN/ {print $2}' /etc/login.defs)..$(awk '/^UID_MAX/ {print $2}' /etc/login.defs)} | cut -d: -f1
List currently logged in users
who
or users
https://www.howtoforge.com/how-to-install-teamspeak-server-on-debian-11/
Create user
sudo adduser ts3 --home /opt/teamspeak --shell /bin/bash --disabled-password
sudo chown -R ts3:ts3 /opt/teamspeak
Delete user
sudo su -
userdel USERNAME