I'd like to use Gradle, but from the User Guide:

For running Gradle, add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

What is the "best" place to add this? I'm the only user of elementary OS.

2 Answers 2


A path set in .bashrc will only be set in a bash interactive non-login shell, it won't be set in applications launched directly from the GUI nor (if you log in remotely) when you log in over SSH. If you put your path in .profile or /etc/profile.d it will be available to your complete desktop session.

Please, change /path/to/your/gradle in my examples with your actual gradle path.
Both solutions will take effect after your next login.

Systemwide setting

There are many ways to set a systemwide variable, but in my opinion the most clean & elegant approach is a separate script in /etc/profile.d.

First, create a new file, make it executable and open it with an editor:

sudo /etc/profile.d/gradle.sh
sudo chmod +x /etc/profile.d/gradle.sh
sudo -i scratch-text-editor /etc/profile.d/gradle.sh

then add the following lines into it:

export GRADLE_HOME=/path/to/your/gradle
export PATH="$PATH:$GRADLE_HOME/bin"

User specific setting

open your local .profile file:

scratch-text-editor ~/.profile

and add the following lines at the end of this script:

export GRADLE_HOME=/path/to/your/gradle
export PATH="$PATH:$GRADLE_HOME/bin"
  • now i know how to add programs in Ubuntu ^_^
    – moldovean
    Commented Apr 15, 2016 at 8:32

You can put it in /etc/environment (it will work for every user) or in your .bashrc file (variable would be valid only through bash) located in your home directory.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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