I have ready bash script, which extensively uses wget command. Unfortunately wget is not available at standard path, but available at:


I was able to make it usable w/o path in bash console, by introducing an alias:

alias wget="/usr/custom/bin/wget"

Still it's not seen from bash script:

./deploy.sh: line 312: wget: command not found

How do I make things work without rewriting the script itself?

P.S. ~/.bashrc is available for editing on the box, so I will be happy to persist those changes.

  • Why not just use /usr/custom/bin/wget (instead of just wget) in your script? Then it should work without problem, and for those using the script, it shouldn't matter how a command in it is called. Most editors have a search-replace function which could quickly do the change (and there is also sed). Nov 11, 2014 at 15:52
  • @BaardKopperud Because scripts must be uniform. I can't search-replace scripts each time I download them from remote repository. It's counterproductive. Nov 11, 2014 at 15:58

4 Answers 4


Add it to your PATH in .bash_profile or .bashrc:

export PATH=$PATH:/usr/custom/bin

This if you only want it for an specific user, if you want it for all users, you could add wget path to /etc/environment.

  • You have to remove wget from PATH. Only /usr/custom/bin/ has to be added.
    – rush
    Nov 11, 2014 at 11:56
  • Fixed. You right. Copy/Paste... you know.
    – jherran
    Nov 11, 2014 at 11:57
  • If you add it to .bashrc, it won't work if the script is launched from a login shell. If you add it to ~/.bash_profile, it won't work unless it was called from a login shell. If this needs to be run without the user having logged in (in a crontab or an init script for example), neither will work. Scripts do not read ~/.bashrc or ~/.bash_profile. They will inherit the $PATH from their parent shell but will ignore those files.
    – terdon
    Nov 11, 2014 at 12:32
  • I can also add /etc/profile. Nov 11, 2014 at 17:25

That is because shell do not support your env aliases by default.

There are two ways to solve this issue:

  1. use #!/bin/bash -i (in case of bash)

  2. add your /usr/custom/bin/ to PATH


You can call your script like this:

PATH=$PATH:/usr/custom/bin/ ./deploy.sh

With this, your PATH is only changed during running process of your script.


You should just extend your PATH in the script. That way other commands in that directory don't clobber your normal use of bash, and you don't have to retype it with every invocation



<rest of your script>

You must log in to answer this question.

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