Linux Sending message from one terminal user to another user

From Ever changing code
Jump to navigation Jump to search
Send a broadcast message to all logged in terminal users
$ sudo wall -n hi
Remote broadcast message (Fri Aug  8 13:49:18 2016):
Send a message to a specific terminal
$ w
 13:54:26 up 2 days, 36 min,  4 users,  load average: 4.09, 4.20, 3.73
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
saml     tty1     :0               Wed13    2days  3:55m  0.04s pam: gdm-password
saml     pts/0    :0.0             Wed13   24:16m  0.35s  0.35s bash
saml     pts/1    :0.0             Wed20    0.00s  3.71s  0.00s w
saml     pts/4    :0.0             01:20   12:33m  0.36s  0.05s man rsync

Send the message

$ sudo echo "Let's go have lunch... ok?" > /dev/pts/4
Send a message to a specific user
$ mesg     #check if you can receive messages 
is n       #y -Allow write access to your terminal; n -Disallow write access to your terminal.

$ mesg y   #enables
$ write saml     #sends message to saml user

Determine which port to use for writing. The '+' or '-' character indicates whether the terminal is writable

[piotr@linux ~]$ who -T
piotr     ? :0           2016-07-27 15:18 (:0)
piotr     + pts/0        2016-07-27 19:58 (:0)
piotr     - pts/1        2016-07-27 21:24 (:0)

Preview default setting of write buffer set it up in the system

cat /etc/default/devpts