Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know you can use write to send a message to a currently logged in user, but how do you leave a message for a user who is not logged in? The solution I have seen is modify the motd, but that will be displayed to all users. How can I leave a message for individual users to read when they login?

share|improve this question
up vote 14 down vote accepted

You can use the mail command to send a message to user jdoe like this:

mail -s "The subject goes here" jdoe

You will enter an interactive environment where you can type your message (mail body). Type Control-D in the beginning of a line to end the message and send it (you will be asked for an optional CC recipient - just hit enter if you don't want one).

You can also do:

mail -s "The subject goes here" jdoe < textfile


echo “John, don't forget our meeting” | mail -s "Reminder" jdoe

The next time jdoe logs in, he will receive a notification like "You have new mail" and he must type mail to read it (perhaps this is a drawback if the user doesn't know he must do this).

share|improve this answer
This is exactly what I was looking for! Now is there a way to show how many new messages there are without opening mail? I'm reading the man page and I don't see a way to do that. I also can't make a bash script that pushes 'q' for me as far as I know. – styfle Sep 24 '11 at 4:30
I noticed that when I login, it says 'You have mail' so that is already solved. But in case anyone is wondering, you can use a script like echo "q" | mail to see how many messages you have. – styfle Sep 24 '11 at 5:13
Note that the mentioned notification is issued by the shell and can be turned off. Supposing you use Bash, see MAIL, MAILCHECK and MAILPATH in the man to know what you can expect. – manatwork Sep 24 '11 at 11:08
You can also run biff to monitor the mailbox. – casualunixer Sep 25 '11 at 0:56

Try wall, http://linux.die.net/man/1/wall Maybe that will do the trick?

share|improve this answer
This is pretty much the opposite of what he wants. He wants a command that leaves a message for a specific, logged out user; wall shows a message to all users currently logged in – Michael Mrozek Jul 1 '12 at 1:44
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Archemar Jun 14 at 13:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.