top of page
  • Writer's pictureMahammad Rafi

6 Commands to list the logged in user in Linux

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 ~]#

9 views0 comments
bottom of page