First time i use asterisk

dear all,

I’m new in asterisk and after i install it in Ubuntu Server ver 16.06. and when i type the <sudo Asterisk -r> its returen (Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)) so i change the permission of the file to 777 by (chmod 777 asterisk.ctl).

after i change the Permission and after i enter <sudo Asterisk -r> i get the below result

root@ubuntu:/var/run/asterisk# asterisk -r
Asterisk 13.1.0~dfsg-1.1ubuntu4, Copyright (C) 1999 - 2014, 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 13.1.0~dfsg-1.1ubuntu4 currently running on ubuntu (pid = 13578)
[Dec 12 06:03:17] NOTICE[13578]: res_config_ldap.c:1710 parse_config: No directory user found, anonymous binding as default.
[Dec 12 06:03:17] ERROR[13578]: res_config_ldap.c:1736 parse_config: No directory URL or host found.
[Dec 12 06:03:17] ERROR[13578]: res_config_ldap.c:1613 load_module: Cannot load LDAP RealTime driver.
ubuntu*CLI> 
Disconnected from Asterisk server
Asterisk cleanly ending (0).
Executing last minute cleanups

any help please ??

Changing files to 777 is never a good idea, and in some cases is detected as a security risk and causes the file to be ignored by the application (not Asterisk).

How did you install Asterisk? What user were you when you tried to run asterisk -r?

Basically you need to run asterisk -r under the same user that created the .ctl file, or run it as root.

thanks David551, i install it as this link http://draalin.com/installing-asterisk-in-ubuntu/

and i was root user when i tried run asterisk -r

and now im getting this message:

root@ubuntu:~# asterisk -r
Asterisk 13.1.0~dfsg-1.1ubuntu4, Copyright © 1999 - 2014, 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 13.1.0~dfsg-1.1ubuntu4 currently running on ubuntu (pid = 14051)
[Dec 12 22:09:16] WARNING[14051]: res_phoneprov.c:1229 get_defaults: Unable to find a valid server address or name.
Registered phoneprov provider ‘sipusers’.
[Dec 12 22:09:16] ERROR[14051]: ari/config.c:296 process_config: No configured users for ARI
[Dec 12 22:09:16] NOTICE[14051]: pbx_lua.c:1640 load_or_reload_lua_stuff: Lua PBX Switch loaded.
[Dec 12 22:09:16] WARNING[14051]: loader.c:522 load_dynamic_module: Error loading module ‘res_pjsip_pidf_body_generator.so’: /usr/lib/asterisk/modules/res_pjsip_pidf_body_generator.so: undefined symbol: ast_sip_pubsub_register_body_generator
[Dec 12 22:09:16] WARNING[14051]: loader.c:1038 load_resource: Module ‘res_pjsip_pidf_body_generator.so’ could not be loaded.
[Dec 12 22:09:16] WARNING[14051]: loader.c:522 load_dynamic_module: Error loading module ‘res_pjsip_exten_state.so’: /usr/lib/asterisk/modules/res_pjsip_exten_state.so: undefined symbol: ast_sip_subscription_get_remote_uri
[Dec 12 22:09:16] WARNING[14051]: loader.c:1038 load_resource: Module ‘res_pjsip_exten_state.so’ could not be loaded.
[Dec 12 22:09:17] WARNING[14051]: loader.c:522 load_dynamic_module: Error loading module ‘res_ari_mailboxes.so’: /usr/lib/asterisk/modules/res_ari_mailboxes.so: undefined symbol: stasis_app_mailbox_to_json
[Dec 12 22:09:17] WARNING[14051]: loader.c:1038 load_resource: Module ‘res_ari_mailboxes.so’ could not be loaded.
[Dec 12 22:09:17] NOTICE[14051]: res_config_ldap.c:1710 parse_config: No directory user found, anonymous binding as default.
[Dec 12 22:09:17] ERROR[14051]: res_config_ldap.c:1736 parse_config: No directory URL or host found.
[Dec 12 22:09:17] ERROR[14051]: res_config_ldap.c:1613 load_module: Cannot load LDAP RealTime driver.
ubuntu*CLI>
Disconnected from Asterisk server
Asterisk cleanly ending (0).
Executing last minute cleanups
root@ubuntu:~#

Sounds like it may be crashing, for which see https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace

Unfortunately, if this is a package, it may have been built with options that make it impossible to debug.

However, from your other error, it does like you have incompatible modules in your modules directory, or have wrong versions of run time pre-requisites (the packager may not have included all the necessary version constraints).