I am trying to write a shell script in Linux Mint, that adds a directory to my path.

the contents of the script successfully adds to my path when I just paste it into the terminal.

But when I invoke the script from within the terminal, nothing happens.

The script I am running, is as follow...

export PATH=$PATH:/opt/android_sdk/platform-tools
  • @MikhailKrutov 's answer is correct. His last sentence really means that in order to modify your current shell's environment, you need to execute your script in it, by source-ing it. Also see answer: askubuntu.com/questions/53177/…
    – Cbhihe
    Oct 6, 2019 at 18:05

1 Answer 1


because when you invoke it, you create a sub shell, which has its own context and its own environment.

When script shell exits, it doesnt' affect the parent shell.

Any environmental variable changes should go through ~/.profile, ~/.bashrc, etc.

if you want it to be a separate script, you should use source /path/to/script instead of executing it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .