Suppose which R returns /opt/anaconda3/bin/R, and suppose I have other R binaries in other locations, and I want a different R binary to run when I type R.

How can I make that happen without

  • deleting any of the R binaries
  • moving any files around

To check that it worked, R should run /some/other/location/R (and which R would return /some/other/location/R)

  • which is a poor choice of command, type -p is better. Unix/Linux shells usually use the PATH environment variable to look for programs. So PATH=/some/other/location:$PATH will change the search order to find a different R.
    – icarus
    Commented Apr 9, 2020 at 4:24
  • @icarus thanks, I will try type -p instead. I thought to change PATH, but could that interfere with other programs? for example if I change the order of paths in PATH, then when I use other programs, it could load the wrong version of the other program?
    – stevec
    Commented Apr 9, 2020 at 4:25
  • @icarus I'm not saying that's a problem btw, I just want to understand what I'm getting myself in for :-)
    – stevec
    Commented Apr 9, 2020 at 4:26
  • 1
    It depends on what else is in /some/other/location - if there is /some/other/location/ls if might be an issue, but if the only binary in /some/other/location is R you will be fine.
    – icarus
    Commented Apr 9, 2020 at 5:11
  • Deja vu. Didnt you aksnthis already?
    – WGRM
    Commented Apr 9, 2020 at 12:02

1 Answer 1


You have a few choices.

  • Change the PATH variable, to make it search directories in a different order. This will affect all programs in there directories.
  • On Debian, use Debian alternatives (Debian and derivatives). And only useful sometimes.
  • Set up a /opt/bin-override directory, add it to the head of the PATH, and add symlinks of commands that you want to run.
  • Add aliases to your ~/.bash_aliases or /etc/bash.bashrc e.g.
    alias R="/some/other/location/R"

You must log in to answer this question.

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