LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I install a program and have it accessible as a command from any directory? (http://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-install-a-program-and-have-it-accessible-as-a-command-from-any-directory-852137/)

bcarl6 12-23-2010 10:01 PM

How can I install a program and have it accessible as a command from any directory?
 
I want to install a program (specifically metasploit), and have it accessible from any directory in the terminal. I have it installed correctly, but I have to travel to the directory it is installed in to run it (by using ./msfconsole ). I want to be able to be in any directory and just run "msfconsole" and have metasploit run. How do I do this? I'm pretty sure that I have to copy the metasploit folder to the /opt/ directory? Maybe the /usr/bin/ directory? I am not sure, and any help would be appreciated. Thanks in advance!

MS3FGX 12-23-2010 10:21 PM

Either symlink the Metasploit binaries to /usr/bin so they are in your path, or add the Metasploit directory to your PATH variable.

chickenjoy 12-23-2010 10:30 PM

Edit .bash_profile of the user:
Code:

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin                                <--- comment out the existing
PATH=$PATH:$HOME/bin:/path/to/metasploit        <--- path to the directory where the program is

export PATH

Now logout and log back in.

Edit: I guess MS3FGX's suggestion is better if you want all existing users and future users to have instant access to the program without having to modify their bash_profile individually.

zer0signal 12-23-2010 10:34 PM

step by step:

at the prompt type

updatedb

wait till it finishes

then

locate msfconsole

once it shows you the path to "msfconsole"

type:

cd /usr/bin

ln -sf /path/to/msfconsole msfconsole

ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
ln [OPTION]... TARGET (2nd form)
ln [OPTION]... TARGET... DIRECTORY (3rd form)
ln [OPTION]... -t DIRECTORY TARGET... (4th form)

that will place a symlink in /usr/bin/msfconsole pointing to >>>> /path/to/msfconsole


you can verify this happend by typing

ls -l in the /usr/bin directory


All times are GMT -5. The time now is 07:03 AM.