I have a couple of system users that have no password set, login disabled and no home directories. They are used solely to run FastCGI processes for a couple of websites.

I want to avoid hard coding in sensitive data into the source code such as passwords and wanted to use environment variables instead so the question is how do you set environment variables for system users with no home directory and no login ability.

Normally I'd just put them in ~/.bashrc but obviously that won't work. I also can't put them in /etc/bashrc since that would mean all users would see the sensitive information.

Has anyone got any suggestions at all? This is on Ubuntu Server 12.04 LTS if that makes a difference.

Edit: As per the comment below I'm using Nginx for the HTTP server.

  • 1
    You might want to say what server you are using, since there is more than one that implements fastcgi and this can possibly be done via the server (e.g., I'd guess mod_env could do this for apache).
    – goldilocks
    Jul 18, 2013 at 14:40

2 Answers 2


You could add a file to /etc/profile.d/ to set variables based on $UID. If you want to fine tune things more based on groups, see man id.

if [ "$(id -u)" -eq 666 ]; then
  • Excellent. Thanks, didn't know you could do this. As per your comment above though I am using Nginx as my HTTP server.
    – Cromulent
    Jul 18, 2013 at 15:52
  • 5
    Interesting choice of UID. I'm guessing this is the standard demon user :D
    – Joseph R.
    Jul 18, 2013 at 15:52
  • 3
    How are you going to prevent other users from seeing this information? The scripts in profile.d need to be world readable.
    – tripleee
    Jul 18, 2013 at 16:16
  • 3
    @tripleee if [ $UID -eq 666 ]; then . /etc/somedaemon/env.sh; fi Jul 18, 2013 at 23:46

chmod +a "username deny read" filename

You must log in to answer this question.

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