Is possible to send a message (popup window or something) to local user logged into X (xdm, fluxbox) from console ? For example: user1 is logged and using X/fluxbox, user2 logging into the same box by ssh to console. Now - what user2 have to do to send message to user1 ?


The xmessage tool lets you do exactly that; present a popup window to users with a text message inside.

Example: user2 logs into a BASH session on the box and issues:

export DISPLAY=':0.0'
xmessage "some message here"

if you log into a TSCH session, it'd be something like this:

setenv DISPLAY ':0.0'
xmessage "some message here'

Alternatively, you can send messages to terminal sessions in one of two ways:

Using wall (=warn all [users])

From the man page:
Wall displays the contents of file or, by default, its standard input, on the terminals of all currently logged in users.

If you want to target a specific user, use write. Again, man tells us:

The write utility allows you to communicate with other users, by copying lines from your terminal to theirs.

  • If a recipient (user1 in my example) is logged into X11, and haven't opened xterm or other terminal - will wall work too ? I think that user1 will not see messages. – marioosh Jul 13 '11 at 7:33
  • I updated my answer to include the 'xmessage' solution. That will show a small window to the user, irrespective of whether they have a terminal open. – mjk Jul 13 '11 at 7:36
  • 1
    Incidentally, 'apropos' is a useful utility to know; it searches manual pages for the text you pass to it. Try running 'apropos message' and see what it returns. – mjk Jul 13 '11 at 7:44
  • I know xmessage but how to run it by user1 and get this small window opened on user2's screen ? is it even possible ? – marioosh Jul 13 '11 at 7:53
  • @marioosh I would also like to know how to do that. Did you ever get it figured out? – user527325 Nov 28 '15 at 20:35

As a rule, X11 sessions are usually started in a “private” mode, so you require one of two things: either, coöperation from user2 to allow you to access their screens, or superuser privileges to “break in” to their screens.

DANGER: Do keep in mind, once you have access to their screen, you could also do things like capture keystrokes (potentially including passwords) and take screenshots, so this is a big security risk.

In most cases it's preferable to instead use a messaging tool or chat program for these things.

Caveats aside:


If user2 wants to allow user1 to access their screen, then first user2 must issue a command like:

 xhost +si:localuser:user1

This could potentially be added to a start-up script of some kind; I don't know Fluxbox, but I assume it has a rc or session-start hook.

Once this has been issed, user1 can then write to user2's display, if they can find it.

If user2 is aware of this, they can always send it to user1 in some other way.

Finding another user's Display

On a typical workstation, it's unusual to have more than one or two users logged in; in which case, “guessing” that the display you want is 0, 1, or maybe 2 might be a workable solution.

However, for a more complete solution, let's assume that you have a machine where very many users could be signed in, and try to find the one you want.

for proc in /proc/[0-9]*/
     if [ Xorg = $(< $proc/comm ) ] 2>/dev/null && \
        [ $(id -u user2) -eq $(< $proc/loginuid) ] 2>/dev/null
        for subproc in $(
            echo "user2 display=" $(perl -ne 'if (m,DISPLAY=(.*)\0,) { print $1 }' < $subproc/environ)

then, user1 can finally (using the DISPLAY value obtained above; I've just written :14.0 here…)

DISPLAY=:14.0 xmessage "Hello, user2"

Sending a Notification instead

In the interests of completeness, the following works on Gnome desktop, at least. I don't know if Fluxbox has a notification widget.

 DISPLAY=:14.0 notify-send "Hello, user2"

This has a lot more user-friendly options for display, and probably will pop up in a rather friendlier way on the user's screen.

  • 2
    for subproc in what? I think your script is corrupted here. – Stéphane Feb 6 '19 at 19:46
  • I'd like to use notify-send (which is how I ended up here), but using DISPLAY=:N.n notify-send only works if I do it as the user I want to send it to -- and if I do it from the GUI, lol (meaning it is totally useless). Otherwise notify-send either does nothing or blocks indefinitely. Did you actually test this when you wrote it? – goldilocks Jan 13 at 23:35
  • It was working with whatever version of Gnome+Fedora were current in 2016, but I haven't rechecked since. I often use notify-send from scripts but usually as "myself" … I suppose some sudo magic could work if the dbus system is more locked-down now? – BRPocock Jan 19 at 15:09

This is a slightly "off the wall" suggestion.

Install espeak (or espeak-ng) on the target machine from your ssh execute

 espeak "The matrix has you"

Espeak is a text to speech engine, and will output to the console's speakers. If the volume is not set to zero, this will cause the computer to speak to the local user.

  • 1
    pun intended... – James K Jun 13 '20 at 11:39

For anyone who could not get notify-send to work by setting DISPLAY to that of the target user, you can use that or any other command by reading from a pipe that messages can be sent to.



if [ ! -e $fifo ]; then mkfifo $fifo; fi

echo $BASHPID > $dir/bash.pid

while [ -e $fifo ]; do
    read line < $fifo
    notify-send "$line"

You can then run this in the background with setsid -f ./whatever.sh (or autostart it via your DE). Other users and system processes can then notify by writing to the FIFO (eg. "echo hello > /home/you/notify-pipe/notifications"). If your home is not publicly readable the pipe can be anywhere.

To stop it you'll have to kill it or delete the pipe. Beware that a pitfall of this is that if the pipe exists but nothing is reading from it (eg. the script), writing a message (eg. via echo) will block until something does read it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.