I am trying to run i3lock which relies on the USER variable for the password to unlock the computer. I am running this on Fedora 24.

I need this to be in a shell script because it is being executed by acpid.

export USER=myusername

But the USER variable is still set to the root. How can I set this environment variable from the shell script?


1 Answer 1


If we look at the source for (a version of) i3lock, we can see it determines the user whose password is required by doing getuid(). So setting the environment variable USER has no effect, and you will need to su or sudo as that user instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .