Search code examples
linuxshellubuntucommand-linemonit

How to create terminal commands for programs installed from source


I recently tried to install monit on Ubuntu Natty from source. Here's my code:

apt-get -y install openssl libssl-dev bison flex
mkdir src && cd src
wget http://mmonit.com/monit/dist/monit-5.3.2.tar.gz
tar xzf monit-5.3.2.tar.gz
cd monit-5.3.2
./configure --prefix=/usr/local/monit
make && make install

However, when I install Monit using apt-get I am able to call monit directly from the command line using the keyword monit. I am not able to do so when I do the install from source. The same goes for PHP.

How can I enable this feature for when I install Monit (and other Linux programs) from source?

Thanks in advance.

EDIT

I was able to solve this by doing the following:

printf "\nPATH=/usr/local/monit/bin:\${PATH}\n" >> ~/.profile
source ~/.profile

This will apply for the currently logged in user (in my case root). To make it system-wide simply replace ~/.profile with /etc/profile.

So now I can can call monit (and any other program I install from source).


Solution

  • Edit your /etc/profile to add the path /usr/local/monit to the PATH variable.

    For ex, if you earlier had this.

    PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

    You could change it to

    PATH="/usr/local/monit:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"