To change the
PATH
environment variable you should export it (the
export command will write it to the environment):
PATH=$PATH:~/bin
export PATH
Without the
export command, the variable will be only set for the actual shell session but not for commands executed in that session or other shell sessions.
The simplest solution would be to save the script in a directory that is already searched. With Linux, there is a directory for such scripts:
/usr/local/bin.
If it should be only executed by the user who created it, add the above to the shell settings for the user (
~/.bash_profile or
~/.profile). With
bash execute then the
source command with the config file as argument to apply the settings (or log out and in again).
If you want to remove a path that has not been added to the global settings (e.g.
/etc/environment) and the user settings (
~/.bash_profile or
~/.profile) just log out and in again. Otherwise edit those files.