Solved

Send message to all the consoles and show connected users

Posted on 2009-05-15
6
793 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

828 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