mesg Command

Purpose

Permits or refuses write messages.

Syntax

mesg [ n | y ]

Description

The mesg command controls whether other users on the system can send messages to you with either the write command or the talk command. Called without arguments, the mesg command displays the current workstation message-permission setting.

The shell startup process permits messages by default. You can override this default action by including the line mesg n in your $HOME/.profile file. A user with root user authority can send write messages to any workstation, regardless of its message permission setting. Message permission has no effect on messages delivered through the electronic mail system (sendmail).

If you add mesg y to your $HOME/.profile, you will be able to receive messages from other users via the write command or the talk command.

If you add mesg n to your $HOME/.profile, you will not be able to receive messages from other users using the write command or the talk command.

Flags

Item Description
n Allows only the root user the permission to send messages to your workstation. Use this form of the command to avoid having others clutter your display with incoming messages.
y Allows all workstations on the local network the permission to send messages to your workstation.

Exit Status

This command returns the following exit values:

Item Description
0 Receiving messages is allowed.
1 Receiving messages is not allowed.
>1 An error occurred.

Examples

  1. To allow only the root user the permission to send messages to your workstation, enter:

    mesg  n

  2. To allow everyone the permission to send messages to your workstation, enter:

    mesg  y

  3. To display what your current message-permission setting is, enter:
    mesg
    Information similar to the following is displayed:

    is  y

    In the previous example, the current message-permission setting is y (allowing all users on the local network the permission to send messages to your workstation). If you change the message-permission setting to n (allowing only the root user the permission to send messages to your workstation), information similar to the following is displayed:

    is  n

Files

Item Description
/dev/tty* Supports the controlling terminal interface.
$HOME/.profile Controls startup processes and daemons.