Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On Linux you can use update-alternative to change the version of a command.

Which command in OS X (10.8) will switch the alternative of the current command?

share|improve this question
There's no such thing on OS X. What command are you talking about? What problem are you facing or why are you asking? Knowing this would give you a better answer. – slhck Jan 3 '13 at 21:21
@slhck One reason one might want this is for the ability to use multiple versions of java, if working on multiple projects that require different versions. – Eric Wilson Mar 27 '15 at 9:48
up vote 3 down vote accepted

I understand the motivation behind your question. update-alternatives elegantly solves the problem of managing several installed versions of a program (for example Java) or different ports of a program (vim vs. elvis vs. vile) by making one of them the default one.

update-alternatives, found in many Linux distros, creates and manages a set of symlinks from /bin, /usr/bin (and the like) to /etc/alternatives, and from there to the location where the program is installed.

For example, in openSUSE java is symlinked to /etc/alternatives/java, which is symlinked to a "private" path where java resides:

/usr/bin/java -> /etc/alternatives/java
/etc/alternatives/java -> /usr/lib64/jvm/java-1.5.0-sun-1.5.0/jre/bin/java

Unfortunately, and although some think it would be necessary, at least for MacPorts, there is no such thing in OS X. I have personally solved the lack of update-alternatives with aliases in my .bashrc:

alias ls='/usr/local/bin/ls'

or simply changing $PATH:


If you can't solve it like this and are weighing the fact of porting it to OS X be aware that although update-alternatives' first incarnation was a Perl script, it was rewritten in C for Debian, and some other distros adopted it later (for instance openSUSE 12.1).

openSUSE 11.4 provides the Perl version as an RPM package. If you are looking for the C version, go for any recent Ubuntu or Debian release, or openSUSE 12.1 or later.

share|improve this answer

In stock OS X there is no more than one version of a command line program installed. In general they are quite outdated. If you like to install a newer version and switch to it, use a package manager like port and its port select command which is an equivalent to update-alternative.

share|improve this answer
Does MacPorts offer alternatives to stuff that's built into OS X? I only remember Homebrew having a non-duplicate policy, meaning that they won't provide formulas for newer versions of commands that already exist on OS X. – slhck Jan 3 '13 at 21:25
macports offer current versions of bash, nano, make, etc... – Max Ried Jan 3 '13 at 21:26
Oh, alright. System duplicates for Homebrew are here, just in case the OP wants to use that instead: – slhck Jan 3 '13 at 21:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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