Archive for October 9th, 2012

Enable write “write” command between logged in users on Debian GNU / Linux

Tuesday, October 9th, 2012

efault Debian GNU / Linux install does not permit messaging between ssh logged in users. Messages are disabled like this for security reasons as if they are on by default it is quite easy to flood one’s terminal with messages using a little loop like for instance:


while [ 1 ]; do
echo "You're flooded" | mesg username
done

Hence smartly, all users between write is switched off, i.e. mesg n

For those unfamiliar with mesg I suggest you check man mesg – which is one of the shortest UNIX manual written 🙂

Mesg head manual description is:


mesg - control write access to your terminal

Options mesg can accept are either yes or no ( y / n ).
To check on current logged in user if write username messaging is turned on, on any logged in user shell use:


# mesg
mesg is n

While mesg is set to no by default, if you try to message a random logged in system user you will get a message like:


$ write testuser
write: write: you have write permission turned off.

It is actually, quite handy to have messages switched on especially if you have a Linux host with user accounts which are friends of yours and
it is not very likely mesg is used for bad.

To change the default mesg n to mesg y you need to edit /etc/bash.bashscr (in case if all users are configured to use bash) or even better to set mesg y for all existing users add a new line on top or at the end of /etc/profile file:


echo 'mesg y' >> /etc/profile

On next login via ssh or physical tty, messaging will be on. To check re-login and type:


$ mesg
is y

One note to make here, is even though if you set messaging to yes for all users via /etc/profile, still for some reason the root user m
essaging keeps set to NO.


$ mesg
is y

One note to make here, is even though if you set messaging to yes for all users via /etc/profile, still for some reason the root user m
essaging keeps set to NO.


root@debian:~# mesg
is n

I have no clue, like this happens, but if you need to enable mesg to root as well add mesg y to /root/.bashrc

Well that’s all, I hope this helps someone 🙂 Cheers.