PBX CLI essentials — the commands you'll actually use
The Asterisk® CLI (asterisk -rvvv) is where you actually see what's happening when a call doesn't behave the way the GUI suggests it should. FreePBX® and bare Asterisk both expose the same CLI; if you know these commands, you can debug 90% of PBX issues without the GUI's help.
Connecting to the CLI
asterisk -rvvv # connect with verbose level 3
asterisk -rvvvvv # verbose level 5 (more chatter)
The vs control how much Asterisk prints. More vs = more detail. asterisk -r is the bare attach (no verbosity bump).
Exit with exit or Ctrl-D. Doesn't restart Asterisk; just detaches the CLI.
Looking at what's running right now
core show channels # active calls (one line each)
core show channels concise # machine-parseable, useful for scripts
core show channels verbose # extra detail per channel
core show calls # call count summary
core show uptime # process uptime + reload uptime
Active call output:
Channel Location State Application(Data)
SIP/101-00000abc 1234@from-internal:1 Up Dial(SIP/trunk1/15555551234)
SIP/trunk1-00000abd s@macro-dial:23 Up AppDial((Outgoing Line))
2 active channels
1 active call
SIP endpoint state (chan_sip and PJSIP)
If you're on chan_sip (older):
sip show peers # all registered endpoints
sip show peer 101 # detail for extension 101
sip show registry # outbound registrations (trunks)
sip set debug peer 101 # log all SIP traffic for this peer
sip set debug off # stop debug
If you're on PJSIP (newer, FreePBX 14+ default):
pjsip show endpoints # all configured endpoints
pjsip show endpoint 101 # detail
pjsip show registrations # outbound trunk registrations
pjsip set logger on # enable SIP logging
pjsip set logger off # disable
Dialplan inspection
dialplan show # entire dialplan (long!)
dialplan show from-internal # specific context
dialplan show 1234@from-internal # specific extension
dialplan reload # apply changes from extensions.conf
FreePBX rebuilds the dialplan from its database; if you edit extensions.conf directly, FreePBX's "Apply Config" overwrites you. Use extensions_custom.conf for hand-edits that survive FreePBX writes.
Module management
module show # all loaded modules
module show like sip # filter by name
module reload chan_pjsip.so # reload a specific module without full restart
core reload # reload all reloadable modules
core restart now # FULL restart (drops all active calls!)
core restart gracefully # restart once no active calls remain
Logging in context
The CLI shows logs in real-time once you're attached. For historical investigation:
tail -f /var/log/asterisk/full # active log
tail -f /var/log/asterisk/messages # rotated daily
# CDR (call detail records)
asterisk -rx "cdr show status" # backend used (mysql, csv, etc.)
FreePBX setups usually have CDR in MariaDB; query directly:
mysql asteriskcdrdb
SELECT calldate, src, dst, duration, disposition FROM cdr ORDER BY calldate DESC LIMIT 20;
Common targeted debug
"Why isn't extension 101 registering?"
pjsip show endpoint 101 # is it configured?
pjsip set logger on # see live SIP traffic
# Try registering from the phone — watch the CLI for INVITE/REGISTER attempts
pjsip set logger off
"Why does this call route to the wrong destination?"
core set verbose 5
dialplan show 1234@from-internal
# Make the call, watch the CLI for each app it traverses
"Why is the trunk down?"
pjsip show registrations
# State should be Registered for outbound trunks
Common gotchas
- "This command is not registered" — the module providing it isn't loaded.
module show like cdrtells you what's loaded. - Changes via CLI don't survive restart unless persisted. Dialplan in
extensions.confis loaded at start; CLI edits to in-memory state are temporary. FreePBX's "Apply Config" persists; direct CLI edits don't. - Verbose output overwhelms. Drop verbosity (
core set verbose 0) when investigating specific issues; raise (core set verbose 5) only when actively chasing one call.
For a structured one-shot dump of all the above (active channels + endpoint status + outbound registrations + uptime), the ct_asterisk_state diagnostic verb covers the typical snapshot in one call.
Also Read
Powered by WHMCompleteSolution