Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 20378  / 3 Years ago, tue, august 3, 2021, 9:54:22

I am logged into Ubuntu server via ssh and I would like to know if another user is logged in via SSH as well. Is there a command that I can run to accomplish this?


More From » ssh

 Answers
3

Just type who:


~$ who
(unknown) tty7 2013-12-06 13:37 (:0)
john pts/0 2013-12-08 00:16 (192.168.0.100)
jane pts/1 2013-12-08 00:17 (192.168.0.101)



EDIT


Regarding your bonus question :)


To see login history for users you can use last -i. This will show all logins and IP addresses since start of current logfile /var/log/wtmp.


Depending on your logrotate you can show previous logs with last -f /var/log/wtmp.1, too.


To only show the very last login for each user use last -i | sort -r | uniq -w 16


~$ last -i | sort -r | uniq -w 20
wtmp begins Sun Dec 1 16:54:49 2013
john pts/0 192.168.0.100 Sun Dec 8 18:49 still logged in
jane pts/1 192.168.0.101 Sun Dec 8 00:17 - 00:34 (00:16)

[#28088] Wednesday, August 4, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rowbris

Total Points: 419
Total Questions: 122
Total Answers: 101

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;