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:
PATH=/usr/local/bin:$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.
Answer from jaume on Stack ExchangeI 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:
PATH=/usr/local/bin:$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.
Macports supports this capability via 'port select' for many language packages, mysql, and others. (I'm using version MacPorts 2.4.2.)
OS update alternative to download? - Apple Community
linux command --> macos command equivalent
macos - How to update Java to 7 on max OSX? - Stack Overflow
MacUpdater alternatives? - Software - MPU Talk
What is the best app updater for Mac?
Is MacUpdater safe to use?
Can App Cleaner & Uninstaller update apps?
Videos
linux command --> macos command equivalent
I came across an linux sudo command that I need to port to macos.
sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force
This command should set the priority when calling ninja to /usr/local/bin/ninja (* Am I right? *)
What's the equivalent command for MacOS?
EDIT:
This is the 3 lines of codes that I need to port to MacOS.
The third is for a specific environment for a python program to run.
!wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
!sudo unzip ninja-linux.zip -d /usr/local/bin/
!sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force
Oracle Java 7 and Apple Java 6 are completely different and they coexist on the same machine as they inhabit totally separate locations.
Java 7, if installed, lives in:
/Library/"Internet Plug-Ins"/JavaAppletPlugin.plugin/Contents/Home
Java 6, if installed, lives in:
/System/Library/Frameworks/JavaVM.framework/Versions/A/
(And the more traditional Java 6 JDK is at: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home)
When you type java, you're running /usr/bin/java, which is a symbolic link to Java 6. In fact, if you type ls -l /usr/bin | grep -i java you will see a bunch of symbolic links for the typical JDK/JRE executables.
So if you have installed Java 7, and that's what you want to use from the command line, you can change into its directory and run its specific binaries in bin. To avoid that, you can add its bin directory to your Bash search path, so its contents are invoked instead of the Java 6 symlinks in /usr/bin. To do this, alter /etc/paths to add the bin directory before the first line:
{ echo "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin"; \
cat /etc/paths; } | sudo tee /etc/paths > /dev/null
Then set the JAVA_HOME environment variable, so supporting software knows where to find Java 7:
{ echo -n "export JAVA_HOME=";
echo "/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"; } \
| sudo tee -a /etc/bashrc > /dev/null
Now, in any new Terminal window, when you type java -version, you'll see java version "1.7.0_51". (And if you still want to be able to run the Java 6 binaries, you can call them with /usr/bin/java, /usr/bin/javac, etc.)
You could try issuing the following command:
update-alternatives –config java
That command will make you able to choose between Java versions. This command worked for me on a Linux-based machine, so I think there would be no different than a Mac, but I'm not sure, you could try it out.
Are there any reliable alternatives to MacUpdater as of October 2025, that would find all the available updates? Most apps don't have a Homebrew package...