My question seems to be trivial but I didn't manage to find anything helpful in internet. I have a binary in


but it is outdated and newer version is available on some mount for example


An there's a bash script that invokes this binary in a form like

binary -doSomething

I need this script to invoke new version of binary instead of old one but I'm not permissioned to change this script. Is is a way to somehow override path to it but only for my user? Any help would be appreciated.

  • If you are not allowed to do it, talk to your admin.
    – Sven
    Oct 24 '13 at 12:10

If the binary is in /usr/bin/binary and the script invokes the binary without specifying the full path, but instead relies on /usr/bin being in PATH then you can simply add the location of the new binary to the beginning of the user's PATH. Put something like this in their ~/.bashrc:


For security reasons, scripts often specify the full path to binaries to prevent this kind of thing.


If you have access to the binary you can backup it and create a symbolic link.

mv /urs/bin/binary /urs/bin/binary.bkp
ln -s /mount/new_version/binary /urs/bin/binary


Sorry, didn't saw the change must be done for one user only.

You can create a function to be called instead of the binary.

Depending on how you execute the binary (full path or just name) you must create a suitable function, like:

# Full path
function /urs/bin/binary () { command /mount/new_version/binary "$@"; }
export -f /urs/bin/binary
# Name
function binary () { command /mount/new_version/binary "$@"; }
export -f binary

If the binary don't accept/need arguments, remove the "$@".

To automatize the function creation, put the function lines in the .profile file in the user home directory.

  • This will affect all users. It's not acceptable. Oct 24 '13 at 12:22
  • Sorry, I corrected the answer as the change must affect one user only.
    – Douglas P.
    Oct 24 '13 at 13:56

alias commandname=/mount/new_version/binary

in the .bashrc above the path statement/export or in the profile will accomplish easy enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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