How can I find out as what user a command executes? (I'm running Ubuntu, but I suspect the answer applies to Unix in general).

What I'm trying to do is get msmtp running and logging to /var/log/msmtp. I've set the owner and group of that file to mail, then added my user to the mail group via sudo adduser dandv mail:

$ ls -al /var/log/msmtp.log
-rw-rw---- 1 mail mail 0 Jul 24 18:45 /var/log/msmtp.log
$ groups dandv
dandv : dandv mail sudo

Yet when when I run

cat testmail | msmtp dan@example.org -v

I get a permission denied:

msmtp: cannot log to /var/log/msmtp.log: cannot open: Permission denied

What is msmtp's problem?

  • groups dandv tells you what groups the user dandv would get if he logged in now. Run groups with no argument to see what groups your session's processes are in. – Gilles 'SO- stop being evil' Jul 25 '14 at 20:11

Uh. Apparently I had to logout and login again for my user's addition to the mail group to take effect. Lame.

| improve this answer | |

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