By default, all the Linux systems accept standard input from another user connected in the same network using the βwall
β or βwrite
β commands.
It is possible due to the terminalβs ability to write messages received from another user on the screen; check out our article on Stdin, Stdout, and Stderr Streams in Linux, including what TTY is, to learn more.
The ability to receive messages from another network user and write them to your terminal can be enabled or disabled using the mesg command.
In this quick tutorial, you will learn how to check all the users and specific user terminal write access and how to set or stop the terminalβs permission for writing messages.
Tutorial Details
Description | Check or set a terminalβs ability to receive messages from other users. |
Difficulty Level | Low |
Root or Sudo Privileges | No |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | mesg |
Internet Required | No |
Usage of the Mesg Command
The mesg command takes two arguments: one will be the option, and the other will be βy
β or βn
β (all are optional).
$ mesg [OPTION] [y | n]
The following are known options offered by this command:
Options | Description |
---|---|
-v | Explain what is being done in more detail. |
-h | Display the help section. |
-V | Display the version information. |
Now letβs see how you can check your terminalβs write access or how you can allow or disallow receiving messages sent by someone on the network.
Check Your Terminalβs Write Access
By default, the permission to write messages on the terminal is enabled in all Linux distributions, and you can check your status by executing the following command:
$ mesg
Output:
The above output indicates that the permission to write messages on my terminal screen is enabled. If you get βis n
β in the output, it means the permission is disabled.
Check Terminal Write Access for Other Users
The previous method only tells you your own terminal write permission; however, using a utility like βwho
β can assist you in checking the terminal write access of other users on the same network.
For example, the following command with the β-T
β flag will print the terminal status next to each user account name that is active on the same network.
$ who -T
Output:
The following is the list of all the possible permissions:
- β
+
β β The terminal is writable. - β
-
β β The terminal is not writable. - β
?
β β Bad line encountered.
Removing Terminal Write Access
If you have the writable permission on your terminal and want to deny any messages from other users (mostly it will be the sysadmin), then you can execute the following command.
$ mesg n -v
Output:
Once you deny write access to your terminal, any user in your local network attempting to send you messages via the wall or write command will be unsuccessful.
1. Sending the messages using the wall command to the denied user
As you can see from the above picture, the βdavid
β user with denied terminal write access was unable to receive the messages sent via the wall command.
2. Sending the messages using the write command to the denied user
In this case, the write command directly prompts the sysadmin that the βdavid
β user has disabled terminal write access.
Allowing Terminal Write Access
If you denied writable permission on your terminal intentionally or unintentionally and want to receive the messages sent by your sysadmin, then execute the following command to enable terminal write access:
$ mesg y -v
Output:
Once you allow write access to your terminal, any user in your local network attempting to send you messages via the wall or write command will be successful.
1. Sending the messages using the wall command to the allowed user
As you can see from the above picture, if the userβs terminal access is enabled, then only the message sent by sysadmin or anyone else using the wall command will be received.
2. Sending the messages using the write command to the allowed user
As you can see from the above picture, the sysadmin and βdavid
β user are able to communicate with each other.
Wrap Up
Now, before I end this article, Iβd like to say that if the sysadmin (or sender) has turned off terminal write access, they can still use the wall command to send messages to everyone, but they canβt use the write command to talk to another user.
Apart from that, the rest of the things are self-explanatory, so I donβt think any additional things should be mentioned in this article.
However, if something is missing or if you have any questions or queries, then reach out to us via the comment section.
Till then, peace!
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.