Solved

Send message to all the consoles and show connected users

Posted on 2009-05-15
6
785 Views
Last Modified: 2013-12-16
Hello,
I would like to know how many ssh sessions are connected to my Linux and if it is possible also the username used and the ip address.

I would like also to know what is the command that I can run by console, so that this message will be shown to all the other ssh remote consoles.

Thanks
0
Comment
Question by:ping_it
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
thetmanvn earned 400 total points
ID: 24393343
1.
root@test:~# who
root     pts/0        2009-05-15 11:35 (192.168.x.x)
root     pts/1        2009-05-15 15:47 (192.168.x.y)

2.

root@test:~# wall
hello
<------------ Press Ctrl+D
Broadcast Message from root@test
        (/dev/pts/1) at 15:51 ...

hello
0
 
LVL 8

Expert Comment

by:thetmanvn
ID: 24393354
More information, you could see who and wall manual.

http://linux.about.com/library/cmd/blcmdl1_who.htm
http://linux.about.com/library/cmd/blcmdl1_wall.htm

Hope this help.
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 100 total points
ID: 24393416
Hi,

This command will give you the users connected and ssh connections:

lsof -i | grep ^sshd | grep EST | awk '{ print $3, $8 }'

You can broadcast it to all connected usrs with wall as thetmanv suggested like that:

lsof -i | grep ^sshd | grep EST | awk '{ print $3, $8 }' | wall

Cheers,
K.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24393579
BTW who will show all interactive logins including console and telnet and SSH.

Cheers,
K.
0
 
LVL 5

Author Comment

by:ping_it
ID: 24393721
thanks
0
 
LVL 30

Expert Comment

by:Kerem ERSOY
ID: 24393753
You're welcome :)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now