-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux logname Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to logname on Linux, covering Arch Linux, CachyOS, and other distributions including login name display, user identification, and username retrieval.
Basic usage:
# Show login name
logname
# Output: usernameLogin user:
# Login username
logname
# Shows original login usernameLogin username:
# Original login
logname
# Shows username of original loginAfter switching:
# After su
su otheruser
logname
# Still shows original login nameDifference:
# logname vs whoami
logname # Original login
whoami # Current user
# After su:
# logname = original user
# whoami = current userUse in scripts:
#!/bin/bash
ORIGINAL_USER=$(logname)
CURRENT_USER=$(whoami)
echo "Original login: $ORIGINAL_USER"
echo "Current user: $CURRENT_USER"Check installation:
# logname is part of coreutils
# Usually pre-installed
# Check logname
which lognameThis guide covered logname usage, login name display, and user identification for Arch Linux, CachyOS, and other distributions.
- whoami Guide - Current user
- id Guide - User and group IDs
- who Guide - Logged in users
-
logname Documentation:
man logname
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.