For some reason I'm not able to write to other users on my system.
[root@hostname ~]# write
write: you have write permission turned off.
[root@hostname ~]# mesg y
[root@hostname ~]# mesg
is y
[root@hostname ~]# write
write: you have write permission turned off.
What else needs to be enabled/corrected for this to work?
Testing
strace write
andstrace mesg
reveals a slight difference in how they identify your tty.write
will first doreadlink("/proc/self/fd/0", ...)
to find the name of thetty
and then do astat
call on the resulting path.mesg
on the other hand will callfstat(1, ...)
which skips the step of usingreadlink
and doesn't rely on the/proc
file system.Notice that they also look at different file descriptors
0
vs1
. Normally an interactive shell will have file descriptors0
,1
, and2
all referencing the same tty. If you have somehow gotten your shell running with0
and1
referencing something different for example if you had redirected one of them, that could explain the discrepancy between the output frommesg
andwrite
.If the file descriptors are both referencing the same tty, another possible reason for the discrepancy could be that your
/proc
mount is not behaving as expected or the character device inode for your tty has been replaced.When running as root with
mesg
disabled (returningn
), I get the same error you have. Running the commandmesg y
enables me to run write. Running asroot
I can write to users that havemesg
disabled, which I can't do as non-root.There are multiple utilities that provide the
write
functionality. All of them will need to be able to write to terminals. However, as you are running asroot
permissions should not be an issue.I had to edit
/etc/login.defs
and changeTTYPERM 0600
toTTYPERM 0620
.