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.

Problem: During Android development, in order to add ADB path to environment variable; I did following things in short-

gedit /etc/environment - Added my desired path in the file such as :/media/Software/00.AndroidLinux/ADT/sdk/platform-tools

But, What I noticed that, adding path to the file has no effect to $PATH until I reboot my Ubuntu.

My question is, How can I add path to /etc/environment variable, and without restarting Ubuntu?, So that I can work with my modified $PATH.

Please Note: I'm new to Ubuntu and learning each day.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Strictly speaking you can't since that file is only read on login, by pam_env. You can however source it in your current shell to read in the values.

$ . /etc/environment
share|improve this answer
add comment

You can add to your $PATH variable directly like this:

export PATH=$PATH:/the/dir/you/want/to/add

Then, edit /etc/environment.

An alternate method would be to still export as I showed above, but then to add the entry to your ~/.bashrc file (if using BASH shell).

echo "export PATH=$PATH:/the/dir/you/want/to/add" >> ~/.bashrc
source ~/.bashrc

EDIT: Exporting your $PATH in your ~/.bashrc file rather than /etc/environment keeps you from needing to elevate permissions to edit a "global" (system) config file and also keeps other users (if you have any on your system) from having that path auto-added on account creation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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