Shows your current username.
whoamistudent
Linux Beginner Series โข Module 4
Learn how Linux knows who you are, what you can access, when you need admin power, and how users join teams like devops. Think of it as a secure office building with ID cards, departments, and one very dangerous master key. ๐
student@linux-vm:~$
Every logged-in account has numeric IDs behind the friendly names.
Beginners often think users and groups are just names. In Linux, they are the base of permissions. Linux asks three questions again and again: Who are you? Which team are you in? Are you allowed to do this?
Linux displays friendly names like student and devops, but internally it tracks numeric IDs. Names are for humans. Numbers are for the operating system.
A user is an account that can own files, run commands, and log in if allowed.
A group is a team of users. Permissions can be given to a whole group.
User ID. Example: the first normal user is commonly UID 1000 on Ubuntu.
Group ID. Every group has a number, just like every user has a UID.
| Concept | Beginner meaning | Command to inspect |
|---|---|---|
| Current user | The account you are using right now. | whoami |
| UID/GID/groups | Your numeric identity and team memberships. | id |
| User database | Local account records. | getent passwd username |
| Group database | Local group records and members. | getent group groupname |
When troubleshooting permissions, first run whoami, then id. Those two commands usually explain half the mystery.
root is the super administrator. sudo runs one command with admin rights. su switches identity to another user. Useful? Yes. Dangerous? Also yes. Handle like a sharp knife, not a spoon. ๐ช
UID 0. Can change system files, create users, install packages, and break things very efficiently.
Temporary admin approval for a command, for example sudo useradd testuser.
Switch user. Example: su - testuser starts a login shell as testuser.
| Feature | sudo | su |
|---|---|---|
| Meaning | Run a command with elevated rights. | Switch to another user account. |
| Common example | sudo useradd testuser | su - testuser |
| Password used | Usually your own password, if you are allowed to sudo. | Usually the target user's password. |
| Beginner memory line | Borrow power for one task. | Become someone else. |
Do not practise destructive commands as root on a real system. A wrong root command can remove users, damage files, or change permissions across the system.
Click an identity. Watch how the same concept appears as human-friendly names and numeric IDs.
Normal learner account
idThese files look scary only because they are compact. Once decoded, they are just structured records.
testuser:x:1001:1001::/home/testuser:/bin/shgetent passwd testusergetent asks the system account database. This works better than assuming everything comes only from local files.
devops:x:1002:testusergetent group devopsThis should show the group name, placeholder, GID, and listed members.
Each command has a job. Learn the job first; memorization becomes much easier.
Shows your current username.
whoamistudent
Shows UID, primary GID, and group memberships.
iduid=1000(student) gid=1000(student) groups=1000(student),27(sudo)
Creates a new user account.
sudo useradd testuserNo output usually means success.
Sets or changes a user's password.
sudo passwd testuserNew password: Retype new password: passwd: password updated successfully
Creates a new group.
sudo groupadd devopsNo output usually means success.
Adds a user to a supplementary group without removing existing groups.
sudo usermod -aG devops testuserNo output usually means success. Verify with: id testuser
Run these commands on your Linux VM. Use a lab VM, not a production machine. The expected UID/GID numbers may differ on your system; the names should match.
whoamiExpected: your current login name, such as student or jp.
idLook for uid=, gid=, and groups=. If you see sudo, your user can likely run admin commands.
sudo useradd testuserExpected: usually no output. Silence in Linux often means success. Very dramatic, very Linux.
sudo passwd testuserExpected: password prompts. Typed passwords will not appear on screen; that is normal.
sudo groupadd devopsExpected: usually no output. If it says group already exists, continue with verification or choose another group name.
sudo usermod -aG devops testuserImportant: use -aG, not just -G. -a means append.
id testuseruid=1001(testuser) gid=1001(testuser) groups=1001(testuser),1002(devops)
Victory condition: devops appears in the groups list.
getent passwd testuser
getent group devopsThese commands verify the records without manually opening system files.
-G without -aBad: sudo usermod -G devops testuser
Better: sudo usermod -aG devops testuser
-aG appends. Without -a, existing supplementary groups may be replaced.
For the modified user, group membership may require a new login session to fully apply.
Verification command: id testuser. For your own user, log out and log in again.
Many Linux admin commands print nothing when successful.
Verify instead of guessing: getent passwd testuser and getent group devops.
Use sudo for specific tasks instead of living inside a root shell unless you truly need it.
Less time with the master key = fewer accidental disasters.
Your mission: create testuser, create devops, attach the user to that team, and prove it with id testuser.
Use these only in your lab VM when you want to remove the practice user and group.
sudo userdel -r testuser-r removes the user's home directory and mail spool where applicable.
sudo groupdel devopsIf the group is still a primary group for a user, Linux may refuse to delete it.
Click an answer and get instant feedback. No exam pressure โ just tiny brain push-ups.
Keep this section handy while teaching or practising.
whoamiShow current username.idShow current UID, GID, and groups.id testuserShow identity details of testuser.sudo useradd testuserCreate a new user.sudo passwd testuserSet password for testuser.sudo groupadd devopsCreate a new group.sudo usermod -aG devops testuserAdd testuser to devops safely.getent passwd testuserCheck testuser in account database.getent group devopsCheck devops group and members.su - testuserSwitch to testuser login shell.sudo userdel -r testuserRemove lab user and home directory.sudo groupdel devopsRemove lab group.