To see the connected users on your server, you can use the shell commands: w, who or users. You can use the three commands without any parameters. For more options run the commands with the –help argument.
In the examples below, you can see there are three logged in users – you can see their IPs, logged-in time etc.
The w shell command:
root@s04 [~]# w 01:42:08 up 22 days, 23:37, 3 users, load average: 0.43, 0.58, 0.66 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 220.127.116.11 01:40 1:12 0.04s 0.04s -bash tony pts/1 18.104.22.168 01:41 8.00s 0.03s 0.03s -bash adam pts/2 22.214.171.124 01:48 0.00s 0.03s 0.00s w
As you can see, the header os the result will show the current time of the server, the uptime, how many users are connected and the server load for the last 1, 5 and 15 minutes.
The next lines will show for each user – the login name, tty name, the Ip of their host, login time, idle time, JCPU, PCPU, and the current command line.
The who shell command:
root@s04 [~]# who root pts/0 Jan 19 01:40 (126.96.36.199) tony pts/1 Jan 19 01:41 (188.8.131.52) adam pts/2 Jan 19 01:48 (184.108.40.206)
The who command is very similar to w.
The users shell command:
root@s04 [~]# users root tony adam
This command will only list the usernames.