Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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
3  
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

 
discard

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.