<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI">Connecting to the CLI</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~mjordan">Matt Jordan</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >You can execute an Asterisk command from outside the CLI: <br>{code} <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">$ asterisk -rx &quot;reload&quot; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">$ asterisk -rx &quot;core reload&quot; <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br>{code} <br></td></tr>
            <tr><td class="diff-changed-lines" >$ asterisk -rx <span class="diff-changed-words">&quot;<span class="diff-added-chars"style="background-color: #dfd;">core s</span>h<span class="diff-added-chars"style="background-color: #dfd;">ow h</span>elp&quot;</span> | grep -i &quot;sip&quot; <br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br>{tip}  <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>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.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[root@server ~]# asterisk -r
</pre>
</div></div>


<p>The &#45;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:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[root@server ~]# asterisk -r
Asterisk version, Copyright (C) 1999 - 2010 Digium, Inc. and others.
Created by Mark Spencer &lt;markster@digium.com&gt;
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&gt;
</pre>
</div></div>

<p>Notice the <b>&#42;CLI&gt;</b> text? That's your Asterisk command-line prompt. All of the Asterisk CLI commands take the form of <b>module action parameters....</b> For example, type <b>core show uptime</b> to see how long Asterisk has been running.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>server*CLI&gt; core show uptime
System uptime: 1 hour, 34 minutes, 17 seconds
Last reload: 1 hour, 34 minutes, 17 seconds
</pre>
</div></div>

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

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

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>server*CLI&gt; quit
</pre>
</div></div>


<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Executing Command Outside Of CLI</b><br />You can execute an Asterisk command from outside the CLI:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">$ asterisk -rx "core reload"</pre>
</div></div>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">$ asterisk -rx "core show help" | grep -i "sip"</pre>
</div></div></td></tr></table></div> 
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817527&revisedVersion=12&originalVersion=11">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Connecting+to+the+CLI?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>