Linux who command

Linux who command

Linux who Command – Check Logged-in Users

The who command in Linux is used to display information about users who are currently logged into the system. It provides details such as usernames, terminal sessions, login times, and IP addresses.

Syntax

who [options]

By default, running who without options lists all logged-in users.

Example Usage

1. List All Logged-in Users

who

Example output:

john tty1 2025-02-09 10:15 alice pts/0 2025-02-09 10:30 (192.168.1.100)
  • john is logged in on the local terminal (tty1).
  • alice is connected via SSH (pts/0) from IP 192.168.1.100.
  • The third column shows the login time.

2. Display User Count

To see the number of users currently logged in:

who -q

Example output:

john alice # users=2

This shows two active users.

3. Show Login Details with Headers

To display a detailed view with column headers:

who -H

Example output:

NAME LINE TIME COMMENT john tty1 2025-02-09 10:15 alice pts/0 2025-02-09 10:30 (192.168.1.100)

4. Show Last System Boot Time

To check when the system was last booted:

who -b

Example output:

system boot 2025-02-09 09:45

5. Display Active Processes Started by Users

To see user processes:

who -u

Example output:

john tty1 2025-02-09 10:15 1234 alice pts/0 2025-02-09 10:30 5678
  • The last column shows the process ID (PID) of the user session.

6. Check Current Runlevel

To display the current system runlevel:

who -r

Example output:

run-level 5 2025-02-09 09:45

This indicates the system is running in graphical mode (runlevel 5).

7. Check Dead Processes

To view processes that have died:

who -d

Difference Between who, whoami, and w

CommandDescription
whoLists all logged-in users with session details.
whoamiDisplays the current user's username.
wShows logged-in users along with their active processes and system load.

Conclusion

The who command is useful for monitoring logged-in users, system uptime, and session details. It is commonly used by system administrators for security auditing and session tracking.

Would you like additional details or modifications for SEO optimization? 🚀

Souy Soeng

Souy Soeng

Our website teaches and reads PHP, Framework Laravel, and how to download Admin template sample source code free. Thank you for being so supportive!

Github

Post a Comment

CAN FEEDBACK
close