-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux whoami Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to whoami on Linux, covering Arch Linux, CachyOS, and other distributions including user identification, current user information, and system user checks.
whoami displays current username.
Uses:
- User identification: See who you are
- Scripts: Check current user in scripts
- Troubleshooting: Verify user context
- Security: Confirm user identity
Why it matters:
- Clarity: Know current user
- Scripts: User-aware scripts
- Debugging: Troubleshoot user issues
Display username:
# Show current user
whoami
# Output: usernameUse in scripts:
#!/bin/bash
USER=$(whoami)
echo "Current user: $USER"Show logged in users:
# Show who's logged in
who
# Show with details
who -aUser information:
# Show user ID
id
# Show specific user
id username
# Show groups
id -GnShow users and activity:
# Show logged in users
w
# Show specific user
w usernameScript example:
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "This script must be run as root"
exit 1
fiVerify user:
# Check current user
whoami
# Check if root
if [ "$(whoami)" = "root" ]; then
echo "Running as root"
fiCheck installation:
# Check whoami
which whoami
# Usually in coreutils
# Install if missing
sudo pacman -S coreutilsThis guide covered whoami usage, user identification, and related commands for Arch Linux, CachyOS, and other distributions.
- User and Groups - User management
- id Command - User information
-
whoami Documentation:
man whoami
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.