How to send a message to all users in a Linux network?
What tools can be used to display messages on the screens of remote users in Linux? It would be ideal to find a solution with a graphical interface that allows asking a question with yes/no answer options.
Multiple Ways to Send Messages to All Users in Linux
In Linux, there are several methods for sending messages to all users on the network, including both console tools and graphical solutions with “yes/no” dialog support. For network interaction, SSH-based methods are most effective, while for graphical interfaces, utilities like zenity and yad are recommended.
Table of Contents
- Local Messaging Tools
- Network and Remote Tools
- Graphical Dialog Tools
- Combined Network Solutions
- Practical Implementation Examples
Local Messaging Tools
Basic Linux tools allow you to send messages directly to the consoles of local users:
The wall Command
The wall (write all) command is designed to send messages to all logged-in users on the local system:
wall "Important message: system will reboot in 10 minutes"
The write Command
For sending messages to specific users:
write username "Your personal message"
The talk Command
An interactive tool for real-time communication:
talk username
Note: These tools only work for users logged into the same physical server.
Network and Remote Tools
For sending messages over the network, Linux offers several approaches:
SSH Message Broadcasting
One of the most reliable ways to send messages to remote Linux machines:
#!/bin/bash
MESSAGE="Urgent notification from administrator"
for HOST in server1 server2 server3; do
ssh $HOST "wall '$MESSAGE'"
done
Using wall Over the Network
If passwordless access is configured, you can send messages to all network users:
# For users on remote machines
ssh user@remote-host "wall 'Your message'"
Mass Mailing Script
#!/bin/bash
# send_message_to_network.sh
MESSAGE=$1
HOSTS=("server1" "server2" "server3")
for HOST in "${HOSTS[@]}"; do
echo "Sending message to $HOST..."
ssh $HOST "wall '$MESSAGE'"
done
Graphical Dialog Tools
Several powerful tools exist for creating graphical dialogs with “yes/no” buttons in Linux:
Zenity - Graphical Dialog Boxes
Zenity is a popular utility for creating dialog boxes in shell scripts:
# Basic yes/no question
zenity --question --text "Are you sure you want to continue?"
# Check response
if [ $? -eq 0 ]; then
echo "User selected Yes"
else
echo "User selected No"
fi
Extended Zenity Capabilities
# Question with custom buttons
zenity --question --text "Install updates?" --ok-label "Yes" --cancel-label "No"
# Question with icon
zenity --question --text "System requires reboot" --icon-name="warning"
Yad - Yet Another Dialog
A more powerful alternative to Zenity with extended capabilities:
# Basic yes/no dialog
yad --question --title="Confirmation" --text="Do you want to delete this file?"
# With progress bar
yad --question --text="Processing files..." --progress-text="Processing"
Dialog - Classic Utility
# Console yes/no dialog
dialog --yesno "Continue with installation?" 8 40
# Process response
case $? in
0) echo "Yes";;
1) echo "No";;
255) echo "Cancel";;
esac
Combined Network Solutions
Complete Script for Network Messages with GUI
#!/bin/bash
# network_message_gui.sh
# Check if message was provided
if [ $# -eq 0 ]; then
MESSAGE=$(zenity --entry --title="Network Message" --text="Enter message to send:")
else
MESSAGE="$1"
fi
# Confirm sending
if zenity --question --text="Send message '$MESSAGE' to all servers?"; then
HOSTS=("server1.example.com" "server2.example.com" "server3.example.com")
for HOST in "${HOSTS[@]}"; do
if ssh $HOST "wall '$MESSAGE'"; then
zenity --info --text="Message successfully sent to $HOST"
else
zenity --error --text="Error sending to $HOST"
fi
done
zenity --info --text="Broadcast completed"
else
zenity --info --text="Sending cancelled"
fi
Cross-Platform Mailing Script
#!/bin/bash
# cross_platform_message.sh
MESSAGE=$1
# Linux servers
for HOST in linux-server-1 linux-server-2; do
ssh $HOST "wall '$MESSAGE'" &
done
# Windows clients (if smbclient is installed)
if [ -x "$(command -v smbclient)" ]; then
echo "$MESSAGE" | smbclient -M workstation-1 -U guest &
echo "$MESSAGE" | smbclient -M workstation-2 -U guest &
fi
zenity --info --text="Message sent to network"
Practical Implementation Examples
Example 1: System Reboot Notification
#!/bin/bash
# reboot_notification.sh
MESSAGE="System will reboot in 5 minutes. Please save all your work!"
# Local users
wall "$MESSAGE"
# Remote servers
SERVERS=("web-server" "db-server" "app-server")
for SERVER in "${SERVERS[@]}"; do
ssh $SERVER "wall '$MESSAGE'" &
done
# Graphical confirmation
zenity --info --text="Reboot notifications sent"
Example 2: Interactive User Polling
#!/bin/bash
# user_poll.sh
QUESTION="Should we install security updates?"
# Local poll
if zenity --question --text="$QUESTION"; then
LOCAL_ANSWER="Yes"
else
LOCAL_ANSWER="No"
fi
echo "Local user answered: $LOCAL_ANSWER"
# Network poll
ANSWERS_FILE="/tmp/user_answers.txt"
echo "Local: $LOCAL_ANSWER" > "$ANSWERS_FILE"
for HOST in server1 server2 server3; do
ssh $HOST "
if zenity --question --text='$QUESTION'; then
echo '$HOST: Yes' >> /tmp/answer
else
echo '$HOST: No' >> /tmp/answer
fi
" &
done
wait
# Collect all answers
for HOST in server1 server2 server3; do
scp $HOST:/tmp/answer >> "$ANSWERS_FILE"
done
# Show results
zenity --text-info --filename="$ANSWERS_FILE" --title="Poll Results"
Example 3: Network Status Monitoring with Notifications
#!/bin/bash
# network_monitor.sh
while true; do
# Check server availability
for HOST in server1 server2 server3; do
if ! ping -c 1 $HOST > /dev/null 2>&1; then
MESSAGE="ATTENTION: Server $HOST is unavailable!"
# Local notification
wall "$MESSAGE"
# Send to other servers
for OTHER in server1 server2 server3; do
if [ "$OTHER" != "$HOST" ]; then
ssh $OTHER "wall '$MESSAGE'" &
fi
done
# Graphical warning
zenity --warning --text="Problem detected with server $HOST"
fi
done
sleep 300 # Check every 5 minutes
done
Sources
- How to Send a Message to Logged Users in Linux Terminal
- Communicating with other users on the Linux command line
- Zenity: A Graphical Dialog Box Utility for Linux
- yad Command Linux: Complete Guide to Yet Another Dialog Tool
- How to send messages or chat in Linux
- Send a ‘net send like’ message from a Linux Host to ALL Linux and Windows computers
- dialog(1): dialog boxes from shell scripts
- Sending messages to another user
Conclusion
- For local systems, use the
wall,write, andtalkcommand-line utilities - For network broadcasting, apply SSH scripts with parallel message sending
- Graphical “yes/no” dialogs are implemented using
zenity,yad, ordialog - Combined solutions allow creating interactive network notification systems
- The most effective approach combines SSH for remote machines and GUI tools for local interaction
For your task requiring a graphical interface with “yes/no” buttons, I recommend using zenity in combination with SSH broadcasting, which will ensure both network message distribution and a convenient user interface for confirming actions.