Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
    
$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
add comment

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

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
add comment

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
add comment

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