Using MTR on OS X without sudo

MTR is awesome, but in a recent update to the package in brew means that you need to sudo to use it. This is particularly a pain when you don’t run as an account that is able to sudo.

In addition, a lot of the functionality of MTR has been moved out into the mtr-packet binary, which makes a lot of the instructions out there on how to resolve this annoyance now wrong.

A quick and dirty fix to get around this is to set the SUID bit, and change ownership to root. You also need both mtr and mtr-packet in your path.

sudo chown root /usr/local/Cellar/mtr/0.94/sbin/mtr-packet
sudo chmod 4755 /usr/local/Cellar/mtr/0.94/sbin/mtr-packet 

ln -s /usr/local/Cellar/mtr/0.94/sbin/mtr /usr/local/bin/mtr 
ln -s /usr/local/Cellar/mtr/0.94/sbin/mtr-packet /usr/local/bin/mtr-packet


Since the release of the M1 processors in macos, the paths required have changed. The following are the new paths.

sudo chown root /opt/homebrew/Cellar/mtr/0.95/sbin/mtr-packet
sudo chmod 4755 /opt/homebrew/Cellar/mtr/0.95/sbin/mtr-packet

ln -s /opt/homebrew/Cellar/mtr/0.95/sbin/mtr /opt/homebrew/bin/
ln -s /opt/homebrew/Cellar/mtr/0.95/sbin/mtr-packet /opt/homebrew/bin/

3 thoughts on “Using MTR on OS X without sudo”

  1. I solved it with a simple script in `/usr/local/bin` plus setting the SUID bit. It has the benefit it survives an upgrade of the package.


    exec /usr/local/sbin/mtr “$@”

Leave a Reply

Your email address will not be published. Required fields are marked *