frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

How to find last logged in users in VPS?

As a Linux system administrator, you should check the login date and time of your server's users on a regular basis. It provides you with information such as how many users are active, how many users are inactive, when and for how long they log in, and so on.

1. w command

In Linux operating systems, there is w command that helps you to find who is logged on and what they are doing in the system. This is the most commonly used command-line tool to display the information about the users currently on the server and their processes.

The w command shows various useful details including the following:

  • the current time;
  • how long the system has been running;
  • how many users are currently logged on;
  • and the system load averages for the past 1, 5, and 15 minutes.

The command output example:

As you can see in the above output, currently there are two users (root and test) logged into Ubuntu server. The w command displays the following details for the individual users:

  1. login name,
  2. the tty name,
  3. IP address from which the user logged in,
  4. login time,
  5. idle time,
  6. JCPU time (the time used by all processes attached to the tty),
  7. PCPU time (the time used by the current process),
  8. and the command line of their current process.

If you want to display the details of a specific logged in user, or example, test, the command would be:

w test

2. who command

The who command is another command that displays information about users who are currently logged in a Linux machine.

The command output example:

2.1 You can filter details for a specific user with grep command:

who | grep ostechnix

2.2 If you want to display information only for the current terminal session, run:

who am i

2.3 You can display all available information of current logins using -a flag:

who -a

3. users command

The users command prints the user names of users currently logged in to the current host system.

  1. last command

The last command usually displays all the users that have ever logged in and out of a Linux machine since the /var/log/wtmp file was created.


There are various commands that you can use to find the last logged in users in your VPS, so feel free to use our provided commands in this guide or other commands that you can ins on the internet.

Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch