Debugging

This is where we have debugging notes.


Asterisk console - asterisk -r
max debug level - core set verbose 999

who -r - to check the init level of the upbx

0 /etc/rc.d/rc0.d/ shutdown/halt system
1 /etc/rc.d/rc1.d/ Single user mode
2 /etc/rc.d/rc2.d/ Multiuser with no network services exported
3 /etc/rc.d/rc3.d/ Default text/console only start. Full multiuser
4 /etc/rc.d/rc4.d/ Reserved for local use. Also X-windows
5 /etc/rc.d/rc5.d/ XDM X-windows GUI mode.
6 /etc/rc.d/rc6.d/ Reboot

To add an extra repository, place a definition file in the /etc/yum.repos.d/ directory on your system
1. root ssh access
2. ran chmod -s * on /bin - don't know what will happen with new load
Fixed - 3. unable to execute unmount in /bin


tcpdump

tcpdump -i eth0 -n -s0 -vvv udp port 5060 -w ./dump2.pcap


Linux Hardware clock

date -s "02/13/2013 20:49:00"
/sbin/hwclock --set --date="02/13/2013 21:04:00" --utc


Linux Software Release Name

cat /etc/*release



Linux Software Release Name

cat /etc/*release



Linux kdump

vi /boot/grub/grub.conf
add crashkernel=128M@16M to the end of the kernel command.  For example:

kernel /vmlinuz-2.6.18-274.7.1.el5 ro root=/dev/VolGroup01/LogVol00 console=ttyS0 rhgb quiet crashkernel=128M@16M

vi /etc/kdump.conf
path /var/crash

chkconfig kdump on
service kdump start

test: - this will panic the machine.
echo 1 > /proc/sys/kernel/sysrq
echo "c" > /proc/sysrq-trigger


Linux Date Command

date -s "11/20/2003 12:48:00"

 ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime


public key authentication ssh

Run ssh-keygen to create the public/private key pair:

    local-host$ ssh-keygen -t rsa -f ~/.ssh/key

Install the private key

Add the following lines to ~/.ssh/config:

    Host *
    IdentityFile ~/.ssh/key

Install the public key on a remote host with OpenSSH

On the remote host, paste the contents of the public key in ~/.ssh/authorized_keys2:

    local-host$ cat  ~/.ssh/key.pub
    remote-host$ paste in ~/.ssh/authorized_keys2


Linux iNode Information

tune2fs -l /dev/mapper/VolGroup00-LogVol00


Firefox

Open a new tab in Firefox and type “about:config” in the browser’s address bar. Then hit the warning message ” I will be careful”, in the following window – right click anywhere and choose “New Boolean”
Enter the name as network.manage-offline-status and set it’s value to false.

network.dns.disableIPv6 = true


chkconfig

chkconfig network --add
chkconfig --level 235 network on
chkconfig --list


Setting DISPLAY env variable.

function get_xserver ()
{
    case $TERM in
       xterm )
            XSERVER=$(who am i | awk '{print $NF}' | tr -d ')''(' ) 
            # Ane-Pieter Wieringa suggests the following alternative:
            # I_AM=$(who am i)
            # SERVER=${I_AM#*(}
            # SERVER=${SERVER%*)}

            XSERVER=${XSERVER%%:*}
            ;;
        aterm | rxvt)
        # Find some code that works here. ...
            ;;
    esac  
}

if [ -z ${DISPLAY:=""} ]; then
    get_xserver
    if [[ -z ${XSERVER}  || ${XSERVER} == $(hostname) || \
      ${XSERVER} == "unix" ]]; then 
        DISPLAY=":0.0"          # Display on local host.
    else
        DISPLAY=${XSERVER}:0.0  # Display on remote host.
    fi
fi

export DISPLAY


CentOS Installer Information

See log messages behind the gui
ctl-alt-F3
ctl-alt-F4
back to the gui
ctl-alt-F1


Ethernet Tool


ethtool eth0 = shows eth0 settings.
ethtool -a eth0
ethtool -K eth0 tso off - Disables TCP Segmentation 

vi /etc/rc.d/rc.local
ethtool -K eth0 tso off


To permanently set:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
ETHTOOL_OPTS="speed 100 duplex full autoneg off"
# /etc/init.d/network restart


Mounting a USB Flash Drive

Start a tail on /var/log/messages to see what device is being used for the usb drive. Make directory to mount to; then mount to usb device.
tail -f /var/log/messages 
mkdir /mnt/flash
mount -t vfat /dev/sdb1 /mnt/flash


Mounting an internal DVD drive

mkdir /mnt/dvd
# This mounts the dvd device read-only (-r) and auto detects the files system type (-t auto).
mount -r -t auto /dev/dvd /mnt/dvd

GZip

gzip --> Add files to a compressed "gz" file.
gunizp <-- Remove files from a compressed "gz" file.

TAR - Tape Archive

tar -tvf archive.tar         # List all files in archive.tar verbosely.
tar -cvf archive.tar         # Create all files in archive.tar verbose
tar -xvf archive.tar         # Extract all files in archive.tar verbose



Root Login SSH

Root Login
vi /etc/ssh/sshd_conf and un-comment #PermitRootLogin yes
ps -ef|grep sshd
kill -HUP <processnum>

Root Login via Xming (GDM Login)

First, edit the file /etc/gdm/custom.conf and add the following two entries:
[xdmcp]
Enable=true

[security]
DisallowTCP=false
AllowRemoteRoot=true

Restart GDM
gdm-safe-restart

Setting up VNC for remote muPBX desktop access

#Install the VNC server if not already installed.
yum -y install vnc-servers

cd /etc/sysconfig
vi vncservers
# Add the following lines
VNCSERVERS="1:admin"
VNCSERVERARGS[1]="-geometry 1280x720"

run "service vncserver restart" - this will create the .vnc directory in the admin's home directory.

su - admin
run "vncpasswd" - Enter a password for admin.
cd .vnc
vi xstartup
#Uncomment "unset SESSION_MANAGER" and "exec /etc/X11/xinit/xinitrc" - see xstart example below.
Add "( while true ; do xterm ; done ) &"
run "exit"  - Exit from admin back to root user.
run "service vncserver restart"

run "chkconfig vncserver on" - This will enable VNC after a reboot.


file:xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &


file:vncservers - non-secure example
#Bunch of comments...#
VNCSERVERS="1:admin"
VNCSERVERARGS[1]="-geometry 1280x720"


Download TightVNC to your PC: Enter your.ip.address:1 to connect to the muPBX VNC server.
Or
Use a Java enabled browser and surf to: http://your.ip.address:5801 (external link) to connect to the muPBX VNC server.
If it doesn't work properly, try rebooting your server or restarting the Xserver. I rebooted.


Setting up xWindows on CentOs 5

Author: http://www.server-world.info/en/note?os=CentOS_5&p=x&f=6 (external link)

NOTE - I found this only works if you have a monitor plugged into the server.

[root@dlp ~]#
vi /etc/gdm/custom.conf

# line 47: add

[xdmcp]
Enable=true
 
[root@dlp ~]#
vi /etc/X11/fs/config
 
# bottom: make it comment
#
no-listen = tcp

[root@dlp ~]#
/etc/rc.d/init.d/xfs restart

[root@dlp ~]# reboot


Installing asterisk


1. Download Asterisk source files using svn.
cd /usr/src

# Latest code:
svn checkout http://svn.digium.com/svn/asterisk/trunk asterisk
svn checkout http://svn.digium.com/svn/dahdi/linux/trunk dahdi-linux
svn checkout http://svn.digium.com/svn/dahdi/tools/trunk dahdi-tools
svn checkout http://svn.digium.com/svn/libpri/branches/1.4 libpri

# Branch code:
Use: http://svnview.digium.com/svn - To view what version of code is desired.

svn checkout http://svn.digium.com/svn/asterisk/branches/1.6.2 asterisk-1.6.2
svn checkout http://svn.digium.com/svn/dahdi/linux/branches/2.2 dahdi-linux-2.2
svn checkout http://svn.digium.com/svn/dahdi/tools/branches/2.2 dahdi-tools-2.2
svn checkout http://svn.digium.com/svn/libpri/branches/1.4 libpri-1.4

2. Make sure the following packages are installed before proceeding:
rpm -q bison
rpm -q bison-devel
rpm -q ncurses
rpm -q ncurses-devel
rpm -q zlib
rpm -q zlib-devel
rpm -q openssl
rpm -q openssl-devel
rpm -q gnutls-devel
rpm -q gcc
rpm -q gcc-c++

If any of the package is not installed, use yum to install it, e.g.,
yum install bison-devel

3. Make sure you establish a link while in the /usr/src directory:
ln -s kernels/kernel_version linux

4. Install the Asterisk files in the following order -> libpri, dahdi-linux, dahdi-tools, asterisk.

# Installing Libpri
cd /usr/src/libpri
make
make install

# Installing dahdi-linux
cd /usr/src/dahdi-linux
make
make install

# Installing dahdi-tools
./configure
optional step: select custom configuration:
make menuselect
make
make install
# To install init scripts and config files:
make config

# Installing Asterisk
cd /usr/src/asterisk
./configure
make menuselect [optional]
make
make install
make samples - Needed for config files.
make progdocs [optional]

5. Verify your Asterisk installation by doing the following:
asterisk -vvvc - launch Asterisk in the foreground mode (not a daemon)
OR
safe_asterisk - connect to its console by typing `asterisk -vvvvvr`.
reload - reload the entire configuration.

Install Asterisk GUI:
cd /usr/src
svn checkout http://svn.digium.com/svn/asterisk-gui/trunk asterisk-gui
cd ./asterisk-gui
./configure
make
make install

Files that need to be modified:

manager.conf
[general]
enabled = yes
webenabled = yes
port = 5038
bindaddr = 0.0.0.0

[admin]
secret = mysecret
;I left the commented ACL deny/permit in for reference.
;deny=0.0.0.0/0.0.0.0
;permit=209.16.236.73/255.255.255.0
read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
write = system,call,agent,user,config,command,reporting,originate


http.conf
[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
prefix=asterisk
enablestatic=yes
redirect = / /static/config/cfgbasic.html


Note: bindaddr 0.0.0.0 means you can access it from anywhere, if you want
access only on the local machine, put 127.0.0.1 instead.

To start Asterisk at boot time, do the following:
cd /usr/src/asterisk-gui
make checkconfig - Check your Asterisk-GUI configuration
cd /usr/src/asterisk
make config - this add the startup script /etc/rc.d/init.d/asterisk

Then issue the following command to be able to start and stop asterisk via service command:
chkconfig --add asterisk


{CODE}
NOTE - I think make install is going to overwrite http.conf and manager.conf. It might be necessary to do the procedure "Setup HTTP Server", again. Running "make checkconfig" should pass if they are okay.
run "make checkconfig"
cd /var/lib/asterisk/static-http
chmod 0777 ./config
asterisk -r - for Asterisk CLI
CLI> reload


To run the GUI use the following URLs.
NOTE - you MUST use the URLs below. Trying to surf to just the ip.address:port will result in some goofy behavior.
http://your.ip.address.here:8088/asterisk/static/config/cfgbasic.html
http://your.ip.address.here:8088/asterisk/static/config/cfgadvanced.html

Removing the color from the Linux terminal

vi /etc/DIR_COLORS
COLOR none
vi /etc/DIR_COLORS.xterm
COLOR none

Remove color from vi:
vi ~/.vimrc
syntax off


Power off muPBX from remote SSH terminal

/sbin/shutdown -h now

Use "top" to monitor processes.

/usr/bin/top

Auto start user defined process after booting.

cd /etc/rc.d
vi rc.local
#Add start command.


Setting up sendmail.

Create script.
/etc/mail/restart.sh
#!/bin/bash
cd /etc/mail
make -C /etc/mail
./newaliases
/etc/init.d/sendmail restart


NOTE - This didn't work.
# Did not modify resolv.conf because it was automagically generated by dhcp.
/etc/resolv.conf File
domain my-site.com
nameserver 192.168.1.100

/etc/hosts File
127.0.0.1       localhost.localdomain localhost linuxsrv1

/etc/mail/access File
Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY

/etc/mail/local-host-names File
# local-host-names - include all aliases for your machine here.
linuxsrv1.micropbxsolutions.com
linuxsrv1

/etc/aliases
# Person who should get root's mail
# Person who should get root's mail
root:           support@micropbxsolutions.com

Note - use "dnl" to comment a line in /etc/mail/sendmail.mc and not "#".
/etc/mail/sendmail.mc

FEATURE(always_add_domain)dnl
FEATURE(`masquerade_entire_domain')dnl
FEATURE(`masquerade_envelope')dnl
FEATURE(`allmasquerade')dnl
MASQUERADE_AS(`linuxsrv1.micropbxsolutions.com')dnl
MASQUERADE_DOMAIN(`linuxsrv1.micropbxsolutions.com.')dnl
MASQUERADE_DOMAIN(localhost)dnl
MASQUERADE_DOMAIN(localhost.localdomain)dnl
EXPOSED_USER(`root')dnl

Testing:
mail -v username
tail the /var/log/maillog


Linux Soft Bridge Ethernet Interfaces

brctl   - prints the available commands.
brctl addbr mybridge
brctl addif mybridge eth0
brctl addif mybridge eth1
ifconfig eth0 0.0.0.0
ifconfig eth1 0.0.0.0
ifconfig mybridge 192.168.100.5 netmask 255.255.255.0 up

/etc/rc5.d/S11bridge
#!/bin/bash
PATH="/sbin:/usr/sbin:/usr/local/sbin";
slaveIfs="1 2 3 4 6 7 8 9 10";
cmd="$1";
[ -z "$cmd" ] && cmd="start";
case "$cmd" in
  start)
    brctl addbr br0;
    brctl stp br0 off;
    brctl addif br0 eth0;
    brctl addif br0 eth1;
    (ifdown eth0 1>/dev/null 2>&1;);
    (ifdown eth1 1>/dev/null 2>&1;);
    ifconfig eth0 0.0.0.0 up;
    ifconfig eth1 0.0.0.0 up;
    ifconfig br0 10.1.1.60 broadcast 10.1.1.255 netmask 255.255.255.0 up;
    route add default gw 10.1.1.1;
    for file in br0 eth0 eth1;
    do
      echo "1" > /proc/sys/net/ipv4/conf/${file}/proxy_arp;
      echo "1" > /proc/sys/net/ipv4/conf/${file}/forwarding;
    done;
    echo "1" > /proc/sys/net/ipv4/ip_forward;
    ;;
  stop)
    brctl delif br0 eth0;
    brctl delif br0 eth1;
    ifconfig br0 down;
    brctl delbr br0;
    #ifup eth0; ### Adapt to your needs.
    #ifup eth1; ### Adapt to your needs.
    ;;
  restart,reload)
    $0 stop;
    sleep 3;
    $0 start;
    ;;
esac;

Yum

yum check-update
yum update

#When yum goes south
yum install yum-utils
yum-complete-transaction


Windows files Linux

Samba is the Linux package for sharing files with Windows SMB.
# Samba client.
/usr/bin/smbclient \\\\yourwindowspcname\\somesubdirectory windowspassword

# Mounting using samba file system.  Note the file system is not the old smbfs it is cifs.
mkdir /mnt/win
mount -t cifs //fqdnoripaddress/somesubdir -o  username=winpcusername,password=winpassword/mnt/win

# For the fstab file to mount the windows drive after a reboot.
//fqdnoripaddress/somesubdir /mnt/win cifs username=winpcusername,password=winpassword 0 0


rsync for backing up files to a locally mounted drive.

# Archive, verbose, compress stream
rsync -avz /tools /mnt/win/linuxsrv1

# Archive restore, verbose, compress stream
rsync -avz /mnt/win/linuxsrv1/tools /



Linux File Permissions

File Mode Drawing by: http://www.unix.com/tips-tutorials/19060-unix-file-permissions.html (external link)

# Transferring files from a windows SMB drive will sometimes set the group file permission with a capital S.
# To fix: 
chmod g+x
chmod g-s

 |------file mode------|
 |                     |
 |
 |       |----full-----|
         |
 |-type| |   |--basic--|
 |     | |   |         |
 oo0 000 000 000 000 000
 ... ... ... ... ... ...
    |     |   |   |   |
    |     |   |   |   |---- rwx for other
    |     |   |   |
    |     |   |   |-------- rwx for group
    |     |   |
    |     |   |------------ rwx for user
    |     |
    |     |---------------- set uid, set gid, sticky bit
    |
    |---------------------- file type: regular (-)
                                       directory (d)
                                       character special (c)
                                       block special (b)
                                       fifo (p)
                                       symbolic link (l)
                                       socket (s)

# To change the user permission to allow execution
chmod u+x filename
#results in: ---x------


# To change everything to allow execution
chmod +x filename
#results in: ---x--x--x

# If you want to set everything on:
chmod 0777 filename
#results in: -rwxrwxrwx


Boot without monitor

This is necessary if you don't leave a monitor plugged into the muPBX and you are running the muPBX in GUI mode (init level 5). Comment out the "splashimage" and add "nomodeset" to the kernel options. See below.
/boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
#splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-164.6.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-164.6.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet nomodeset
        initrd /initrd-2.6.18-164.6.1.el5.img
title CentOS (2.6.18-128.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-128.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet nomodeset
        initrd /initrd-2.6.18-128.el5.img


Finding CentOS Version

rpm -qa|grep centos-release

Asterisk Console Commands

# No HTTP keep-alive messages
core set verbose 3
# Debug 
core set verbose 7

core restart now
# Useful for showing what's configured.
sip show settings

sip show registry


Changing Linux hostname

#Replace Abcdefg with your hostname in the files below.
# Edit network file
vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=Abcdefg

# Edit hosts file
vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost Abcdefg
::1             localhost6.localdomain6 localhost6


Changing Linux IP Address

vi /etc/sysconfig/network-scripts/ifcfg-eth0
vi /etc/hosts
vi /etc/sysconfig/network
vi /etc/resolv.conf
/etc/init.d/network restart



Creating /etc/rc.d/init.d chkconfig --add file

#!/bin/sh
# Starts and stops file.pl
#


case "$1" in
start)

        ./file.pl >> /var/log/file.log&

;;

stop)

        kill $(pgrep file.pl)
;;

restart)
        $0 stop
        $0 start
;;

status)
             if pidof -o %PPID file.pl > /dev/null; then
                     echo "Running"
                     exit 0
             else
                     echo "Not running"
                     exit 1
             fi
;;

*)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac


rpm, svn and yum notes

Installing rpmforge yum repos
# rpm -Uhv http://apt.sw.be/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
createrepo /home/root/rpmbuild/RPMS/x86_64/

 [mupbx]
 name=MPS Server - $basearch
 baseurl=ftp://mupbx/home/root/rpmbuild/RPMS/x86_64/
 enabled=1
 gpgcheck=0
 #gpgkey=file:///path/to/you/RPM-GPG-KEY



Menu [toggle]