Is it possible to use notify-send to send messages to other users on the system?
preferably to a specified user, but system wide would work aswell.

Ubuntu/Debian with libnotify installed

  • See this answer for an example that works with Ubuntu 16.04, even from a script started by root in crontab.
    – mivk
    Feb 12, 2017 at 11:44

4 Answers 4


If you have the other users password you can do sudo -u somedude notify-send Hello. somedude must have an X-session started.

Edit: Found this script for use with cron:

export DISPLAY=:0.0
export $(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -session)/environ )
/usr/bin/notify-send -t 36000 $1 $2
  • with slight modification, that script does what i need it to do, thanks
    – madmaze
    Oct 5, 2011 at 16:49
  • didn't you miss one hyphen before -session?
    – vladkras
    Oct 19, 2016 at 9:05
  • no @vladkras pgrep is supposed to be getting the pid of the X-session manager, i.e. lxde-session, gnome-session etc. That script is a crude hack at best and depends a lot on your system setup. It worked when I answered but doesn't work without modification now, 5 years later.
    – micke
    Oct 21, 2016 at 12:23
  • 1
    It doesn`t work for me either
    – vladkras
    Oct 22, 2016 at 4:23

If the users are on terminals the following commands will be of use -

write user [tty]

or to send to all users


I stumbled upon the following project that implements a user notify: tinynotify-send


I needed similar tool to send notification to all sessions. Here is my solution: https://unix.stackexchange.com/a/230062/93227

It scans /proc to find all session busses and then it executes notify-send on each of it (once per bus). All arguments are passed unchanged to real notify-send.


/bin/grep -sozZe '^DBUS_SESSION_BUS_ADDRESS=[a-zA-Z0-9:=,/-]*$' /proc/*/environ \
| /usr/bin/php -r '
        $busses = array();
        while($ln = fgets(STDIN)) {
                list($f, $env) = explode("\0", $ln, 2);
                if (file_exists($f)) {
                        $user = fileowner($f);
                        $busses[$user][trim($env)] = true;
        foreach ($busses as $user => $user_busses) {
                foreach ($user_busses as $env => $true) {
                        if (pcntl_fork()) {
                                $env_array = array("DBUS_SESSION_BUS_ADDRESS" => preg_replace("/^DBUS_SESSION_BUS_ADDRESS=/", "", $env));
                                pcntl_exec("/usr/bin/notify-send", $argv, $env_array);
' -- "$@"

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.