Switch User and Privileged Commands
su - – Switch to another user with a login shell.
su -l – Same as su -; start a login shell for the target user.
su --login – Same as su -; execute a login shell.
su - root – Switch to the root user with a login shell.
sudo apt update – Update package lists from repositories (requires root privileges).
User Account
grep username /etc/passwd – Check if a user exists
System Account
cat /etc/passwd – Check system account
Group Account
grep "mail" /etc/group – Check group for mail
User User info
id – Shows info about the current user
id username – Show info for a specified user
id -g – Print only the primary group ID
id -G – Print all group IDs (primary + secondary)
cat /etc/group | grep username – Verify user groups
View Current User
who – Shows currently logged-in users
who -b – Show last system boot time
who -r – Show current runlevel
who -b -r – Shows boot time & runlevel
w – detailed info about current users and system load.
Viewing Login History
- last – Shows login and logout history of users