# Asterisk Project : Connecting to the CLI

Added by malcolmd , edited by mjordan on Feb 26, 2013

First, let's show you how to connect to the Asterisk command-line interface. As you should recall from the installation, Asterisk typically runs in the background as a service or daemon. If the Asterisk service is already running, type the command below to connect to its command-line interface.

    [root@server ~]# asterisk -r

The -r parameter tells the system that you want to re-connect to the Asterisk service. If the reconnection is successful, you'll see something like this:

    [root@server ~]# asterisk -r
    Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others.
    Created by Mark Spencer <markster@digium.com>
    Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
    This is free software, with components licensed under the GNU General Public
    License version 2 and other licenses; you are welcome to redistribute it under
    certain conditions. Type 'core show license' for details.
    =========================================================================
    Connected to Asterisk version currently running on server (pid = 11187)
    server*CLI>

Notice the *CLI> text? That's your Asterisk command-line prompt. All of the Asterisk CLI commands take the form of module action parameters.... For example, type core show uptime to see how long Asterisk has been running.

    server*CLI> core show uptime
    System uptime: 1 hour, 34 minutes, 17 seconds
    Last reload: 1 hour, 34 minutes, 17 seconds

You can use the built-in help to get more information about the various commands. Simply type core show help at the Asterisk prompt for a full list of commands, or core show help command for help on a particular command.

If you'd like to exit the Asterisk console and return to your shell, just use the quit command from the CLI. Such as:

    server*CLI> quit

Executing Command Outside Of CLI

Icon

You can execute an Asterisk command from outside the CLI:

    $ asterisk -rx "core reload"

    $ asterisk -rx "core show help" | grep -i "sip"