Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
How to add a directory to my path?

I created a .bash_aliases file with the following contents:

PATH=$PATH:$HOME/opt/bin

So it adds /home/myuser/opt/bin to $PATH. I made this because I don't have root access to this machine.

When I run apps interactively through the shell command line, they can understand my custom PATH with no problems. But, if I open a app outside the shell command line, for example, choosing from the unity dash, the same apps can't see my custom PATH.

I tried putting shopt -s expand_aliases in my .bash_aliases, but without success.

How can I set a PATH for environments other than BASH?

share|improve this question

marked as duplicate by Christopher, gertvdijk, Stephen Myall, Jorge Castro, Tom Brossman Jan 1 '13 at 17:33

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.

add comment

2 Answers 2

up vote 1 down vote accepted

If you're running apps outside the shell command line that will always run with your UID, you can create session-wide environment variables by adding them to ~/.pam_environment, rather than .bash_aliases.

If you're running apps outside the shell command line that will not always run with your UID, system-wide environment variables by adding them to /etc/environment, rather than .bash_aliases.

However: Creating system-wide environment variables will affect ALL users, including root. If the variable you set overwrites another, bad things will happen. Adding something onto the end of PATH doesn't seem like it will cause any havoc, but seeing as you don't have root, you would need your sysadmin to do it for you, and s/he can probably advise you as to whether it is safe to add it. Whether s/he actually allows you to do this is something else entirely; anything user-related is best kept within the config files within their home folder, and it is not normally 'done' to have a users configuration affecting the whole system!

share|improve this answer
    
Thank you for the Answer. I add the following to my ~/.pam_environment: "PATH DEFAULT=${PATH}:~/opt/bin" And I change the line 50 in /etc/pam.d/login for avoid duplicate my env like this: "session required pam_env.so readenv=1 user_readenv=0" –  ayr-ton Jan 1 '13 at 2:39
add comment

The PATH environment variable does not belong in ~/.bash_aliases; a better place is ~/.profile or ~/.pam_environment recently. If you put your path in ~/.profile, it will be available to X and the window managers that use X. Edit ~/.profile. Add to the end of that file:

PATH="$PATH:$HOME/opt/bin"

Maybe you are using Xubuntu? You may need to use ~/.bashrc instead. And ~/.pam_environment:

PATH DEFAULT=${PATH}:~/opt/bin

See help.ubuntu.com on Environment variables.

What does belong in ~/.bash_aliases are command aliases, like this:

alias l=ls
alias ll=ls -l
alias la=la -la
alias x=exit
alias b=my-insanely-long-command-i-never-want-to-type-again
share|improve this answer
add comment

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