• WordPress behind nginx

    if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] )
    && preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/',
    $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];


  • vlc as root

    sed -i 's/geteuid/getppid/' /usr/bin/vlc


  • process

    $ sudo update-rc.d myserver defaults

    To do this, you must create this file and save it in /etc/init.d/.

    #!/bin/sh

    DAEMON="/path/to/myserver.py"
    DAEMONUSER="myuser"
    DEAMON_NAME="myserver.py"

    PATH="/sbin:/bin:/usr/sbin:/usr/bin"

    test -x $DAEMON || exit 0

    . /lib/lsb/init-functions

    d_start () {
    log_daemon_msg "Starting system $DEAMON_NAME Daemon"
    start-stop-daemon --background --name $DEAMON_NAME --start --user $DAEMONUSER --exec $DAEMON
    log_end_msg $?
    }

    d_stop () {
    log_daemon_msg "Stopping system $DEAMON_NAME Daemon"
    start-stop-daemon --name $DEAMON_NAME --stop --retry 5 --name $DEAMON_NAME
    log_end_msg $?
    }

    case "$1" in

    start|stop)
    d_${1}
    ;;

    restart|reload|force-reload)
    d_stop
    d_start
    ;;

    force-stop)
    d_stop
    killall -q $DEAMON_NAME || true
    sleep 2
    killall -q -9 $DEAMON_NAME || true
    ;;

    status)
    status_of_proc "$DEAMON_NAME" "$DAEMON" "system-wide $DEAMON_NAME" && exit 0 || exit $?
    ;;
    *)
    echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|force-stop|restart|reload|force-reload|status}"
    exit 1
    ;;
    esac
    exit 0

    $ sudo chmod 755 /etc/init.d/myserver
    $ sudo chmod 755 /path/to/mserver.py

    http://stackoverflow.com/questions/13718821/run-python-script-as-daemon-at-boot-time-ubuntu


  • proftpd shut down issue

    /etc/init.d/proftpd
    Find this line:
    start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"
    Change to this:
    start-stop-daemon --stop --signal $SIGNAL --retry 1 --quiet --pidfile "$PIDFILE"


  • Mail from CMD

    mail -a "Content-type: text/html;" -s Test address@example.com < mail_html.html


  • ISPConfig 3 SpanAssassin autolearn

    ou can start out by creating a new file in /bin. For example sa_learn.
    nano /bin/sa_learn

    Now once you are in that file you can paste the following:
    #!/bin/bash
    /usr/bin/sa-learn --spam /var/vmail/*/*/.Junk/*/*
    /usr/bin/sa-learn --ham /var/vmail/*/*/cur/*

    The first part to this code is the directory of the SpamAssassin learning script, when putting in the –spam it learns it as spam, and –ham learns it has “good” messages. The second part to this code is the directory to your clients’ spam folders. So once this is all done, you can learn all spam in your customers’ spam folders.
    After you have saved that file by clicking ctrl x, you will want to make it executable by doing the following command:
    chmod o+x /bin/sa_learn

    And then now from the command prompt you can simply type
    sa_learn

    and it will learn spam and ham!


  • Network usage satistics

    iptraf
    bmon
    tcptrack -i eth1


  • FLAC to MP3

    sudo apt-get install flac
    sudo apt-get install lame

    for f in *.flac; do flac -cd "$f" | lame -b 320 - "${f%.*}".mp3; done

    alias flac2mp3='for f in *.flac; do flac -cd "$f" | lame -b 320 - "${f%.*}".mp3; done'


  • find file

    find /home/john -iname "something"


  • Clone drive linux

    dd if=/dev/sda of=/dev/sdb