Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

15
  • Related: Who sets $USER and $USERNAME environment variables Commented Mar 7, 2015 at 9:07
  • Looked at the link, but unfortunately no alternatives to $USER variable produced different output. Commented Mar 7, 2015 at 13:28
  • 1
    The USER variable is set by the login program. Daemons don't have it in their environment. If your script needs to know the userid it's running as, one thing it can do is run the id command. Commented Mar 7, 2015 at 13:49
  • 1
    export USER=$(id -u -n) won't produce any output, but it will set the USER variable. Can you show us the code that is not working, for example, the code that tries to read the config file? Commented Mar 7, 2015 at 20:27
  • 1
    Try adding export HOME=~ . It's odd that mailx doesn't read /root/.mailrc. It does on opensuse, even when HOME is not set. I'll have to install arch to see why. Commented Mar 9, 2015 at 7:54