top of page

6 Commands to list the logged in user in Linux

  • Writer: Mahammad Rafi
    Mahammad Rafi
  • Jan 23, 2019
  • 1 min read

Updated: Apr 5, 2019

Here are 6 commands which I use to view the users who have logged in recently or are currently logged in to any particular Linux machine .



Method 1

users: This command print the user names of users currently logged in to the current host without showing any much information about source, login time or any other relevant detail.

# users

root rafi oracle applprod


Method 2

last: This command searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created. Names of users and tty's can be given, in which case last will show only those entries matching the arguments.




Method 3

secure file: This file contains the logs of all the attempts made for login to your machine with authentication reports.

# less /var/log/secure


Method 4

finger: If no arguments are specified, finger will print an entry for each user currently logged into the system.

[root@net7 ~]# finger

Login Name Tty Idle Login Time Office Office Phone Host

root root tty2 9 Apr 5 15:11

root root pts/0 Apr 5 15:12 (192.168.9.1)

[root@net7 ~]#


Method 5

who: This command shows currently logged in users with time details.

[root@net7 ~]# who

(unknown) :0 2019-04-05 15:10 (:0)

root tty2 2019-04-05 15:11

root pts/0 2019-04-05 15:12 (192.168.9.1)

[root@net7 ~]#


Method 6

whoami: Print the user name associated with the current effective user ID.

[root@net7 ~]# whoami

root

[root@net7 ~]#

Comments


adult-apple-device-business-340152.jpg

Linux .....because life is too short for reboots

I am an avid fan of Linux and open source enthusiast so I make a  decision to meet people through Technical Live Blogger. I have been enjoying Linux for the past six years. Back in 2013, I stumbled upon an article about the Ubuntu live CD. That moment changed my life. I know that statements like that belong to those exaggerators but it is actually true. Within 24 hours of reading the article, I had turned my own desktop in Ubuntu one – a platform where I have explored many Linux things ever since. If you just want to say hello, do say "Hello" at md.rafi1615@gmail.com or visit the virtualworld.

  • LinkedIn Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • Facebook Social Icon

© 2023 by Extreme Blog. Proudly created by Mahammad Rafi

bottom of page