Where can I find the installed package path via brew

I installed some packages via brew. But I can not find where they are.

I can not get access by typing hping on terminal

% brew install hping
(git)-[master] 
Warning: hping-3.20051105 already installed

Solution 1:

Use the following to show the installation path of a package:

brew info hping

Example output:

pcre: stable 8.35 (bottled)
http://www.pcre.org/
/usr/local/Cellar/pcre/8.35 (146 files, 5.8M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/pcre.rb
==> Options
--universal
    Build a universal binary

Solution 2:

To figure out where your formula is installed, do brew --prefix hping

You can also relink your hping binary by doing brew unlink hping && brew link hping

Also maybe your $PATH is not well defined. Does the list given by echo $PATH contains the result given by echo $(brew --prefix)'/bin:'$(brew --prefix)'/sbin'? This path should be toward the beginning of the list to be prioritized over system binaries, surely before /usr/bin.

To do so, you can add this at the end of your ~/.zshrc or ~/.bashrc:

export PATH=$(brew --prefix)/bin:$(brew --prefix)/sbin:$PATH

As a result, after opening a new terminal or doing source ~/.zshrc, you'll be able to echo your correct path as:

$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin