2

I'm trying to install Asterisk on my Debian wheezy server. For this I first did the simple

sudo apt-get install asterisk

This worked flawlessly. Afterwards asterisk was running and I could enter the CLI of it using :

asterisk -rvvv

After some messing around I dumped asterisk and reinstalled again:

sudo apt-get remove --purge asterisk
sudo apt-get install asterisk

This reinstalled successfully, and sudo service asterisk status shows [ ok ] Asterisk PBX is running., but I cannot enter the CLI anymore (asterisk -rvvv says -bash: asterisk: command not found).

So I tried installing it from source using this simple guide. All steps go well, and I can get asterisk up and running again. But yet again, the CLI refuses to start with another -bash: asterisk: command not found).

Does anybody know what I'm doing wrong here? Or can anybody point me in the right direction? All tips are welcome!

bertieb
  • 7,543
kramer65
  • 1,442
  • 4
  • 26
  • 43

1 Answers1

2

How the shell finds your programs

When you type foo in the command-line of your shell, it looks foo up in a set of paths defined by your shell's PATH environment variable (which you can inspect by running echo $PATH).

So my guess is simpe: the asterisk package you had before reinstalling had the asterisk binary located in a place listed in your user's $PATH and the package installed afterwards had it installed elsewhere.

You can check this easily by correlating echo $PATH in your shell with the output of

$ dpkg -L asterisk | grep bin/asterisk

In any case, you can run your binary program by specifying its full pathname.

Pathname resulution caching in the shells

Another possibility, though less likely, is pathname resolution caching. Interactive shells, bash included, only look up a bare program's name through the list in $PATH once, and then remember that full location they've found. If you then remove the program from that location, the shell will be unable to run it anymore, even if the program's file is now accessible in some other place listed in the $PATH.

You can help the shell by running hash -r in it (please see help hash in your bash prompt).

Miscellanea

Note that in the general case, when you do

apt-get remove --purge asterisk
apt-get install asterisk

that is, perform a remove+install cycle, the version of a package as known to the APT system based on the archives made available to it is installed. That is, if you have installed your hand-built version directly via dpkg -i ..., APT won't attempt to find and install this same version when you later remove and install the package with the same name.

If you want to make your hand-built asterisk package be available for general installation, you'd have to maintain a proper local Debian repository (reprepro is properly the simplest tool to use, also see apt-ftparchive), make it known to your local APT system and also possibly make packages from that repository preferred using APT preferences.

kostix
  • 2,976