I want to add PATH on Linux Ubuntu 18.04 from file path.sh , my file include :
#!/bin/bash
export PATH="$PATH:/root/.local/bin"
chmod+x path.sh , but when i run it ./path.sh Path not add when i type echo $PATH .
but when i type in terminal export PATH="$PATH:/root/.local/bin" it added to my PATH .
Am I miss something on my file?
sourcedoesn't fit your needs—is to leverage exported functions and/or aliases to update your PATH.function myPath() { export PATH="/whatever/bin:$PATH" }export -f myPathThen, add this to your.bashrcor equivalent:source ~/myPath.sh(apologies in advance for crappy comment formatting restrictions)bindirectory on an external drive or perhaps a partition that isn't always mounted, mounted at different paths on different machines, etc. Personally I put mymount/umountshortcuts into exported functions like these to handle both mounting and updating the environment (PATH etc) in one swoop.