Server Fault is a question and answer site for system and network administrators. 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

How can I check the mailbox of another user in Linux (CentOS)? Basically I want to replicate the

$ mail

command but when sudo-ed as another user.

Right now if I try to just do

$ sudo -u johndoe mail

I get

/var/spool/mail/jordan: Permission denied

Same thing if I use

$ sudo su johndoe

and then run the mail command.

share|improve this question
up vote 5 down vote accepted

Try this:

sudo su - johndoe -c mail

The - parameter to su should take care of setting up the environment for johndoe so the right mailbox is accessed.

share|improve this answer
Explanation: Without the - you are not getting the target user's full environment. In particular, you aren't getting the MAIL variable set to his mailbox. – Mark Wagner May 31 '11 at 16:46

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.