LinuxCommandLibrary

asterisk

Run the Asterisk open-source PBX software

TLDR

[r]econnect to a running server, and turn on logging 3 levels of [v]erbosity

$ asterisk -r -vvv
copy

[r]econnect to a running server, run a single command, and return
$ asterisk -r -x "[command]"
copy

Show chan_SIP clients (phones)
$ asterisk -r -x "sip show peers"
copy

Show active calls and channels
$ asterisk -r -x "core show channels"
copy

Show voicemail mailboxes
$ asterisk -r -x "voicemail show users"
copy

Terminate a channel
$ asterisk -r -x "hangup request [channel_ID]"
copy

Reload chan_SIP configuration
$ asterisk -r -x "sip reload"
copy

SYNOPSIS

asterisk [OPTION]... [COMMAND]

PARAMETERS

-C filename
    Use filename as Asterisk configuration file instead of default.

-c
    Run in foreground console mode (no daemon).

-d [number]
    Enable debugging at specified level (default 1).

-f
    Do not fork into background (force foreground).

-F
    Force fork into background even if console mode.

-G group
    Run as specified group after startup.

-g
    Run in foreground without daemonizing.

-h
    Display help summary and exit.

-M [module]
    Load only specified module(s) on startup.

-m
    Load only modules marked 'autoload=yes'.

-n host
    Bind to specified IP address or hostname.

-p
    Allow core dumps for debugging.

-P
    Disallow core dumps.

-q
    Quiet startup (reduce log verbosity).

-r
    Connect to running Asterisk instance (remote CLI).

-R
    Wait for asterisk -r connection before daemonizing.

-s socket
    Use custom Unix socket for remote control.

-T
    Do not show CLI timestamps.

-t
    Show CLI prompt timestamps.

-U user
    Run as specified user after startup.

-v
    Increase verbosity (more console output).

-V
    Display Asterisk version and exit.

-x command
    Execute CLI command remotely and exit.

DESCRIPTION

Asterisk is a versatile, open-source software framework for building communications applications, primarily used as a private branch exchange (PBX). It enables voice over IP (VoIP) telephony, video conferencing, IVR systems, voicemail, and integration with traditional PSTN lines via hardware like DAHDI cards.

The asterisk command launches the Asterisk server daemon, provides console access, or executes remote commands on a running instance. Without options, it starts as a background daemon. Key features include support for protocols such as SIP, IAX2, PJSIP, MGCP, and Skinny; flexible dialplan scripting in extensions.conf; and a powerful CLI for management.

Configurations reside in /etc/asterisk/, allowing customization for call routing, user authentication, and media handling. Asterisk is scalable for small offices to large enterprises, often used in FreePBX or custom setups. It handles calls, SMS, and fax, with modules for codecs, encryption (SRTP), and recording. Licensed under GPL v2, it's maintained by Sangoma.

CAVEATS

Requires root privileges for low port binding and hardware access; use safe_asterisk wrapper for security. Misconfigurations can cause DoS or expose services. Not for production without firewall and TLS setup.

CLI USAGE

In console (-c or -r): run core show help, module show, sip show peers for status; core reload to apply config changes.

STARTUP FILES

Checks /etc/asterisk/asterisk.conf, loads modules from modules.conf, executes dialplan in extensions.conf.

HISTORY

Created by Mark Spencer in 1999 at Digium; first public release 2001. Acquired by Sangoma in 2018; evolved from 1.x to current LTS 20.x/21.x series with PJSIP focus and module improvements.

SEE ALSO

safe_asterisk(8), rasterisk(1), asttop(1), asterisk.conf(5)

Copied to clipboard