why brew link mtr not work in macOS catalina

Viewed 2208

I am install mtr in macOS catalina:

brew install mtr

but when I using this command:

/usr/local/sbin ⌚ 22:53:15
$ mtr
zsh: command not found: mtr

and I try to link:

/usr/local/sbin ⌚ 22:52:50
$ brew link mtr
Warning: Already linked: /usr/local/Cellar/mtr/0.93_1
To relink:
  brew unlink mtr && brew link mtr

why the link not work?

2 Answers

I finally found the linked dir not in my macOS path,using this command to check:

env | grep sbin

try to do this to make it work:

# add this line to .bashrc
export PATH=/usr/local/sbin:$PATH

# make it work
source ~/.bashrc

NOTE: For Apple Silicon machines the PATH is different.

Add this line(s) to .bashrc or .zshrc

# Intel
export PATH=$PATH:/usr/local/sbin

# Apple Silicon
export PATH=$PATH:/opt/homebrew/sbin

Run source ~/.bashrc or source ~/.zshrc or close/open your terminal.

Then run mtr as usual

sudo mtr 1.1.1.1
Related