I have Metasploit installed on my Mac in /usr/local/share/msf. Everytime I want to use it I have to cd into that directory and use msfconsole.

If I try to /usr/local/share/msf/msfconsole in my home directory I get an error that gems are missing and I should bundle install but if I cd to msf and run msfconsole it runs with no problems although I have to use sudo -E msfconsole to utilise it fully.

Does anyone know how to add /usr/local/share/msf as an environment called $MSF that I can run its commands as root (sudo -E) and use its dependencies/gems?

I have the same problem for BeEF too but thats a different question.


I'm not sure, but I believe you should add this to your .bash_profile:

export MSF_DATABASE_CONFIG=/usr/local/share/msf/config/database.yml

(edit the path accordingly)

  • Thats the config, which is different and is already done. I installed according to this: darkoperator.com/installing-metasploit-framewor Scroll down to Create Symlink For Regular Use, this was the only part of the tut that never worked.
    – Anonymous
    Jun 14 '15 at 20:33
  • @Anonymous Did you use brew?
    – LaX
    Jun 14 '15 at 21:00

Create a symbolic link somewhere in your path.

 ln -s /usr/local/share/msf/msfconsole /usr/local/bin/msfconsole

You will probably need to do that for things like msfupdate etc. As for the gems, cd to the directory metasploit is in and

bundle install

If you want to add an environment variable then add this to .bashrc, or whatever shell you are using.

export MSF=/usr/local/share/msf

However that doesn't really 'fix' your problem, the first does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.