Ubuntu – Why isn’t adding a path to “.profile” working

environment-variableslubuntu

I am using Lubuntu 12.04.

I am having problems setting the path variable for my application.

I am trying to set the path variable in the .profile file, however after adding the path when I echo $PATH, it does not show my addition.

Here is the line I am adding at the end of the .profile after the 'fi'

export PATH=$PATH:/home/treedev/lib/Qt/bin

Please let me know what I am doing wrong. When I run the above command directly in the bash shell, it works, which leads me to believe I am doing something wrong, but I can't seem to figure out where I am wrong.

Thanks for your time.

Best Answer

To add a system-wide path, simply add to the PATH variable defined in /etc/environment.

  1. Press Alt+F2 and type gksudo gedit /etc/environment
  2. Change the default path:

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
    

    by adding your path to it:

    PATH:"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/treedev/lib/Qt/bin"
    

To add this path only to your session (i.e. for your user only), add to ~/.pam_environment instead:

PATH=$PATH:/home/treedev/lib/Qt/bin

Related: Please see the Ubuntu Wiki on Environment Variables.

Related Question