2

I have a problem with $PATH export. The only place I found where I modify $PATH is /etc/environment:

ANDROID_HOME="/opt/ADT/adt-bundle-linux-x86_64-20130522/sdk"
PROJECT_HOME="/home/tomaszchabinka/Dokumenty/tempFile/android_stb"
PATH="/opt/gradle-1.10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

But when I type in terminal echo $PATH it returns:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/jdk1.7.0/bin

I don't have /usr/lib/jvm/jdk1.7.0/bin directory so I don't understand why my $PATH export doesn't works and where does /usr/lib/jvm/jdk1.7.0/bin come from.

Also $ANDROID_HOME and $PROJECT_HOME exports correctly; only $PATH export doesn't work.

Can anyone help me?

Richard
  • 8,502
  • 11
  • 47
  • 72
pstrag
  • 121
  • 1
  • 1
  • 5
  • You should be placing those types of exports in $HOME/.bashrc or $HOME/.zshrc or whichever shell dotfile corresponds to your environment. If this needs to propagate to new user accounts, place it in /etc/skel/ in the appropriate dotfile. – lazyPower Jan 22 '14 at 11:11
  • I've tried this earlier (with .bashrc and with .profile) and also didn't work – pstrag Jan 22 '14 at 11:20

2 Answers2

3

There are a few places where you can define $PATH:

  • /etc/environment is a plain text file (not a script) that affects all users
  • ~/.pam_environment - the same thing but user-specific

bash also executes some scripts which can be used for modifying $PATH:

  • ~/.profile is executed for a login shell sessions (don't ask me what it means :)
  • ~/.bashrc is executed for non login interactive shell sessions
  • /etc/profile and /etc/bash.bashrc are system wide alternatives for ~/.profile and ~/.bashrc

I read somewhere that /etc/environment is a recommended place for defining your $PATH. So I usually use it. But your path is probably modified in one of the other places.

BTW, when you execute a command with sudo, I think it normally uses root user's $PATH (and not the $PATH of your unprivileged user account). So, ~/.pam_environment, ~/.profile and ~/.bashrc in /root directory may also play a role.

Alexey
  • 188
  • 10
-2

Put this in ~/.bashrc:

PATH="${PATH}:/opt/gradle-1.10/bin"

  • 2
    Welcome to the site and thank you for your input. You answer could be improved by adding a bit more, for example; what the expected result is, if it worked for you and such like. – Phil UK Apr 20 '17 at 22:26