Scenario
A scheduled maintenance window is about to begin. You need to alert everyone currently logged into the host, then notify a specific user that they still have an open session and should log off before the work begins.
This is the kind of quick comms you do right before a reboot, patch cycle, storage maintenance, or network change.
Objective
- List who is logged in and capture TTYs.
- Broadcast a one-line message to all users.
- Send a targeted message to a specific user session.
Concepts
-
You cannot message a specific session without the TTY. Use
whowhen the target matters. -
usersis a fast glance, but it drops session context. Use it when you only need names. -
wallis broadcast. Keep the message short, time-bound, and actionable so users can respond quickly. -
writeis session-targeted. It is useful for the last straggler you need off the host before maintenance. - Messaging can be blocked by user settings. If the target has messaging disabled, you will need another channel.
Walkthrough
who
who is the preferred tool when you need to target a specific session because it includes the TTY, for example
pts/2.
devstudent pts/0 2025-07-19 08:31 (:0)
sysmon pts/1 2025-07-19 08:33 (10.0.0.15)
analyst pts/2 2025-07-19 08:34 (10.0.0.42)
users
users is a quick glance at who is logged in, but it does not show TTYs, so it is weaker for targeted messaging.
devstudent sysmon analyst
wall "System maintenance starts in 10 minutes. Please save your work."
wall writes to all logged-in terminals. Keep it short, actionable, and time-bound.
Broadcast message from root@server01 (tty1) (Fri Jul 19 08:35:12):
System maintenance starts in 10 minutes. Please save your work.
write analyst pts/2
write targets one session, so the TTY must match what you discovered in Step 1. After starting the write session,
type your message and press Ctrl+D to send.
[write session open - type your message and press Ctrl+D to send]
Hi analyst, please log off before 08:45 for scheduled maintenance.
[Message sent]
who -T
If the target has messaging disabled, write will fail. The who -T output shows whether each session accepts messages.
devstudent + pts/0 2025-07-19 08:31 (:0)
sysmon - pts/1 2025-07-19 08:33 (10.0.0.15)
analyst + pts/2 2025-07-19 08:34 (10.0.0.42)
Breakpoints
The target user may have used mesg n. Verify with who -T. If the session is not accepting messages, use another communication channel.
If you only ran users, you do not have the TTY. Run who to get the exact terminal name before using write.
Some terminals or environments may not display wall output as expected. Confirm you have logged-in sessions and that they are real TTYs.
Cleanup checklist
- Confirm the announcement was delivered.
- Confirm the targeted user logged off.
who
last | head
Reference
who: Show logged-in users with TTY and source.-
who -T: Show logged-in users and whether each session accepts messages.+: messaging allowed-: messaging disabled?: unknown
users: Quick list of usernames logged in (no TTY info).wall <message>: Broadcast a message to all logged-in terminals.write <user> <tty>: Send a message to a specific user session; finish input with Ctrl+D.mesg y|n: Enable or disable messages to your terminal.