How to Check, Allow, or Disallow Terminal Write Access in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

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

DescriptionCheck or set a terminal’s ability to receive messages from other users.
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitesmesg
Internet RequiredNo

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:

OptionsDescription
-vExplain what is being done in more detail.
-hDisplay the help section.
-VDisplay 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:

Current terminal permissions

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:

Check other user's terminal permissions

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:

Terminal write access is denied

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

Sending a message to deny terminal write access using the wall command

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

Sending a message to deny terminal write access using the write command

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:

Terminal write access is allowed

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

Sending a message to allow terminal write access using the wall command

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

Sending a message to allow terminal write access using the write command

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.