CLI command error

I have installed asterisk recently and after start of the asterisk server,

when i try to connect the asterisk through commands “asterisk -r” it gives an error

Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

so i tried “asterisk -rvvvvv” , it gives me the same error.
later i tried “asterisk -vvvvc” , it goes to the CLI command line and it doesnt exit.

when i try ‘*CLI> exit’ it shows
No such command exit.
i tried “*CLI> killall -9” it shows the same error.

command giving like asterisk -rx " module show like websocket" also give error like
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

how do I resolve the error?

Unable to connect, means that the server wasn’t running, or there is a permission problem.

Exit not working in -c mode is, I believe expected behaviour. I think you would need to use stop.

killall -9 is something that should only ever be done in a system shutdown sequence, and more generally, kill -9 should only be used if kill -15 (default) hasn’t worked. However, these are shell commands and one wouldn’t expect them to be recognized by the Asterisk CLI, unless prefixed by !.

output of
/etc/init.d/asterisk status

● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/init.d/asterisk; bad; vendor preset: enabled)
Active: active (exited) since Fri 2018-07-13 05:27:20 EDT; 1 weeks 3 days ago
Docs: man:systemd-sysv-generator(8)

Jul 13 05:27:20 L8-Dilip52 systemd[1]: Starting LSB: Asterisk PBX…
Jul 13 05:27:20 L8-Dilip52 asterisk[1136]: ERROR: /usr/sbin/asterisk not found
Jul 13 05:27:20 L8-Dilip52 systemd[1]: Started LSB: Asterisk PBX.
Jul 19 11:18:12 L8-Dilip52 systemd[1]: Started LSB: Asterisk PBX.
Jul 23 06:45:59 L8-Dilip52 systemd[1]: Started LSB: Asterisk PBX.
Jul 23 08:10:47 L8-Dilip52 systemd[1]: Started LSB: Asterisk PBX.

i could go to CLI command line when I use “asterisk -vvvvvc”

Hi.
From your status notice:
Active: active (exited) since Fri 2018-07-13 05:27:20 EDT; 1 weeks 3 days ago

Your server is not running, because it exited (read above).

Try restarting the whole machine and after that try again.
You could also see the ports available for your asterisk instance (usually 5060, 5061) by typing:
netstat -tulpen
from your linux cli.

Hope that helps.
_fuz

Hi.
If rebooting does not help, I made good experience by looking at my full asterisk log. Usually you will find here what was going wrong. The full log is located under var/log/asterisk/full. Make sure you turned on debugging notices for that log when you start your asterisk. If you are not sure, search for “asterisk debugging” or logging. I guess you know what I mean.

Thanks,
_fuz

restart of the whole system resolved the issue. Thanks a lot !