How to show the currently logged in user in linux/unix

Show the current logged-in users is a must in linux/unix, which can help us determine which users are using the terminal window to log in or what they are doing.

In linux/unix, the following commands can display the currently logged in user or user information.

  • w command : Show who is logged on and what they are doing
  • who command : Display who is logged in
  • whoami command : Find out who you are currently logged in
  • id command : See user and group information for the specified USER account

How to show current logged in users in Linux/Unix

Open the terminal window and type:

who

Of course, we can also enter the following command:

w

It can be found that the w command displays more information than the who command. The w command can not only show who the currently logged in users are, but also show what processes they are running and show the system running time, load, etc.

Next, we will introduce the meaning of the content displayed by the w command:

The first line displays, in this order:

  • The current time ( 22:04 )
  • How long the Linux server has been running (36 days)
  • How many users are currently logged on Linux (3 users)
  • The system load averages for the past 1, 5, and 15 minutes (1.83 1.67 1.65)

The following info displayed for each current logged in user:

ylspirit s001     -                21:57       6 vim test.txt
  • ylspirit – Login name
  • s001 – The tty name
  • 21:57 – Login time
  • 6.00s – Idle time
  • vim test.txt – The command line of their current process

Find out who you are currently logged in as on Linux

Execute the following command:

whoami

Another similar function command:

id

This article shows how to find the currently logged in user and what they are doing in linux/unix.

For more information, use the man command to view the man page:

man who
man w
man whoami
man id

Tags:, ,

Add a Comment

Your email address will not be published.