Often Linux system administrators need to be able to send message to logged user in Linux. Although there are various chat applications that help you broadcast messages, there are very few commands that allow you to send messages only to logged users in Linux. In this article, we will learn how to send message to logged user in Linux.
How to Send Message to Logged User in Linux
You can use wall command to send message to logged user in Linux. Here is a sample command to inform all logged users about a 2-hour system downtime.
# wall "System will go down for 2 hours maintenance at 13:00 PM"
When you send the above message, here is what logged users will see on their screens. root@ubuntu will be replaced by your admin username,
Broadcast message from root@ubuntu (pts/2) (Sat Dec 9 13:27:24 2022): System will go down for 2 hours maintenance at 13:00 PM
If you want to disable the broadcast banner in the above message, use -n option.
# wall -n "System will go down for 2 hours maintenance at 13:00 PM"
Alternatively, you can also use write command to send message to users using tty. For this purpose, use who command to list all users in your system.
$ who
Here is an example to send message to user test1.
$ write root pts/2
You will see a prompt to type your message. Press Ctrl+D after the message is typed.
wall is a one-to-many broadcasting message sender while write is a one-to-one messaging tool. You can use either of them depending on your requirement.
In this article, we have learnt how to send message to logged user in Linux. You can also use these commands in your shell script, if you want to automate the broadcast of your messages.
Also read:
How to Update or Change System Locale in Linux
Linux Grep Binary Files for Strings
Linux Prevent File from Being Modified
Linux Rename File With Special Characters
Linux Rename File Starting With Dash
Related posts:
How to Store Command in Variable in Shell Script
How to Improve Ubuntu Speed & Performance
How to Fix Permission Denied Error While Running Shell Script
How to Change Host Name in Debian/Ubuntu
How to Install Go (Golang) in Ubuntu
How to Bring Background Process to Foreground in Linux
How to Install PHPMyAdmin in Ubuntu
Find files with special characters in name Linux
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.