安裝方法:
將下載來的binary檔案移動到 /usr/local/bin 即可在terminal中使用其指令。
可以使用 mv 或者 cp 這兩個指令
用法:
mv [source] [destination]
cp [source] [destination]
說明:
When you type commands like
ngrok in the terminal, Macs (and other Unix OSs) look for these programs in the folders specified in your PATH. The PATH is a list of folders that's specified by each user. To check your path, open the terminal and type: echo $PATH.
You'll see output that looks something like:
/usr/local/bin:/usr/bin:/bin. This is a : separated list of folders.So when you type
ngrok in the terminal, your Mac will look for this executable in the following folders: /usr/local/bin, /usr/bin/ and /bin.像我目前如果在terminal中輸入 echo $PATH 則會出現:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Library/TeX/texbin
代表這些地方都有存放可在terminal中執行指令的程式
各個path的比較:
/bin(and/sbin) were intended for programs that needed to be on a small/partition before the larger/usr, etc. partitions were mounted. These days, it mostly serves as a standard location for key programs like/bin/sh, although the original intent may still be relevant for e.g. installations on small embedded devices./sbin, as distinct from/bin, is for system management programs (not normally used by ordinary users) needed before/usris mounted./usr/binis for distribution-managed normal user programs.- There is a
/usr/sbinwith the same relationship to/usr/binas/sbinhas to/bin. /usr/local/binis for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. You should not install them into/usr/binbecause future distribution upgrades may modify or delete them without warning./usr/local/sbin, as you can probably guess at this point, is to/usr/local/binas/usr/sbinto/usr/bin.
In addition, there is also/optwhich is for monolithic non-distribution packages, although before they were properly integrated various distributions put Gnome and KDE there. Generally you should reserve it for large, poorly behaved third party packages such as Oracle.
參考資料:
https://stackoverflow.com/questions/30188582/ngrok-command-not-found
https://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux
https://linux.die.net/man/7/hier
沒有留言:
張貼留言