This question already has an answer here:

I have exported the PATH but once I switch to a different terminal or reboot Debian, $PATH is reset. Here are the steps I take:

~$ vim scripts.sh

echo "Hello"

I save it as mybash.sh and chmod with 755. Then I move it to my /root/scripts directory.


~$ export PATH=$PATH:~/root/scripts

and it works, but once I reboot Debian, close or switch into another terminal, mybash.sh cannot be called.

Why doesn't it store PATH permanently?

marked as duplicate by Gilles bash May 21 '15 at 23:07

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.

  • You might want to prepend rather than append. – PSkocik May 21 '15 at 10:02
  • 1
    Why don't you place your script in /usr/local/sbin, which is included in root's PATH ? – user86969 May 21 '15 at 11:29

You can add the line to the /etc/enviroment file like this:



Edit your ~/.bashrc and add your line here like this:

export PATH=$PATH:~/root/scripts
  • 1
    No. You misspelled /etc/environment, the syntax you used doesn't work there (variable expansion only works in shell scripts, this is not a shell script), and .bashrc only works partially (it sets the variable only in programs launched from a terminal). None of this is correct. – Gilles May 21 '15 at 23:09

Edit your ~/.bashrc file and add your export PATH line to it.

  • No. .bashrc only works for programs launched from a terminal. – Gilles May 21 '15 at 23:09
  • @Gilles, I quote from the question: "...into another terminal...", and therefor do not understand your comment. Can you please clarify your comment? – Lambert May 22 '15 at 7:50
  • @Lambert .bashrc is only read in a terminal. So modifying PATH there will only take effect in programs that are launched via a terminal. That takes care of the specific example where the program is launched from a terminal, but not of the general case where the program is launched from somewhere else. – Gilles May 22 '15 at 8:28
  • 1
    @Gilles, thanks for your explanation. The OP asked how to set the PATH variable permanently for new terminals so the answer to that is, in my opinion, still valid. I agree that you can not rely on it in all cases (ie. when calling from a custom binary started from the desktop, of using a different shell like zsh) but in this case it is obvious that bash is being used and that the script is called from a terminal window. – Lambert May 22 '15 at 8:53

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