Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How do I set a user environment variable? (permanently, not session)

I have a user XX and I want to set the env variables for it. I looked for .bash_profile in the home dir but there was none. SO, I tried with .bashrc, but when I try to see the env variables (printenv), my variables are not there. This is killing me. I tried for root, and it works. But it does not work for user XX.

share|improve this question

marked as duplicate by Gilles, Ulrich Dangel, Renan, Stéphane Gimenez, jasonwryan Aug 22 '12 at 0:36

This question was marked as an exact duplicate of an existing question.

$HOME/.bashrc or $HOME/.bash_profile should work. check for the file permission and ownership, it should be owned by user. and login and re-login, if your root user use 'su - userid' to swtich to user. – sfgroups Aug 2 '12 at 2:58
There is no .bash_profile file. There is .bashrc and .profile – cindy Aug 2 '12 at 3:42
@cindy .profile is the right place. – Gilles Aug 2 '12 at 22:59

export MYVARIABLE="variable-value"

This only works if user XX's default shell is bash since you added the variables in .bashrc.

share|improve this answer

It should work. You may need to have the user log back in or source the .bashrc file to reload it (. ~/.bashrc), but you shouldn't set your env. variables in .bashrc.

You can also create a new .bash_profile file containing XX's exports and modify his .bashrc to make sure it gets loaded with:

if [ -f ~/.bash_profile ]; then . ~/.bash_profile; fi

share|improve this answer
No, don't set environment variables in .bashrc. Set them in .profile. See Alternative to .bashrc – Gilles Aug 2 '12 at 22:58

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