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*

10
  • 1
    Is there a group named $USER? getent group $USER Commented Feb 5, 2015 at 20:20
  • 1
    $USER variable is set during interactive login. How do you run your script - from login session or using cron or from daemon? Commented Feb 5, 2015 at 20:31
  • 1
    Check if the USER variable is even seen by the script. If you add a line to your script that says echo USER is $USER, what does it print out? Commented Feb 5, 2015 at 22:12
  • 1
    @BrassApparatus I guess technically you'd want to use $(id -nu):$(id -ng) to get the user and the group. Commented Feb 7, 2015 at 10:39
  • 1
    Try using $U or anything else, but not $USER, because this variable is special for sudo. See man sudo section ENVIRONMENT. Commented Feb 7, 2015 at 14:24