mac 安裝 mtr
macOS 上要安裝 mtr 看似簡單
$ brew install mtr
如果沒安裝過 HomeBrew 請參考這邊
mtr 可拿來檢查點對點中間的網路狀態
它結合 ping 及 traceroute 的功能
已內建於大多數的 Linux 中
詳細的說明可參考這邊
但這邊有個坑
由於安裝好的 mtr 不在 /usr/local/sbin 中
macOS 中也不存在這這個目錄(macOS 10.14.3)
所以會出現以下的錯誤
Error: The
brew linkstep did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink sbin/mtr
/usr/local/sbinis not writable.
You can try again using:brew link mtr
==> Caveats mtr requires root privileges so you will need to runsudo mtr. You should be certain that you trust any software you
grant root privileges.
執行 brew link mtr 會出現
Linking /usr/local/Cellar/mtr/0.92…
Error: Could not symlink sbin/mtr
/usr/local/sbin is not writable.
如何設定
1. 建立目錄及設定權限
sudo mkdir /usr/local/sbin &&
sudo chmod ug+rwx /usr/local/sbin &&
sudo chown $(id -un):admin /usr/local/sbin
2. 設定 PATH
如果有裝 zsh 的話
請編輯 vi .zshrc
如果沒有使用 zsh 請編輯 vi .bash_profile
將下面的部分貼到最下方
export PATH=$PATH:/usr/local/sbin
3. link mtr
brew link mtr
4. 測試 mtr
sudo mtr www.google.com
PS. 可能要重開 terminal
我的環境
- macOS 10.14.3
參考資訊
0.92 mtr: Failure to start mtr-packet: Invalid argument on macOS 10.12 #204
mtr tries to install to nonexistant directory #22085
Comments