• Create .deb file

    Create a directory to make your package in. The name should be the same as the package name.
    mkdir helloworld_1.0-1

    Pretend that the packaging directory is actually the root of the file system. Put the files of your program where they would be installed to on a system.
    mkdir helloworld_1.0-1/usr
    mkdir helloworld_1.0-1/usr/local
    mkdir helloworld_1.0-1/usr/local/bin
    cp "~/Projects/Hello World/helloworld" helloworld_1.0-1/usr/local/bin

    Now create a special metadata file with which the package manager will install your program…
    mkdir helloworld_1.0-1/DEBIAN
    gedit helloworld_1.0-1/DEBIAN/control

    Put something like this in that file…
    Package: helloworld
    Version: 1.0-1
    Section: base
    Priority: optional
    Architecture: i386
    Depends: libsomethingorrather (>= 1.2.13), anotherDependency (>= 1.2.6)
    Maintainer: Your Name <you@email.com>
    Description: Hello World
    When you need some sunshine, just run this
    small program!

    (the space before each line in the description is important)

    Now you just need to make the package:
    dpkg-deb --build helloworld_1.0-1

    Script files in /DEBIAN/ folder
    Postinst means: "AFTER the files have been Copied To the iDevice, THEN Run this Script."
    Preinst means: "BEFORE the files Get Copied To the iDevice, Run this Script, THEN Copy the files To the iDevice."
    Postrm means: "AFTER the files have been Removed From the iDevice, THEN Run this Script."
    Prerm means: "BEFORE the files Get Removed From your iDevice, Run this Script, THEN Remove the files From the iDevice."

    Sample postinst:
    #!/bin/bash
    cd /var/mobile/Applications/*/Game.app
    mkdir Backups
    cp -a ./Original_File.ext ./Backups/Original_File.bak
    killall Game
    mv -f /var/mobile/Documents/GameMod/Game/* ./
    exit 0


  • 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


  • Mail from CMD

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


  • icecast on 80

    iptables -A PREROUTING -t nat –dst 8.8.8.8/32 -p tcp –dport 80 -j DNAT –to 8.8.8.8:8080

    iptables -A INPUT -p tcp -m state –state NEW –dport 80 –dst 8.8.8.8/32 -j ACCEPT


  • htaccess

    izveidot jaunu
    htpasswd -c /home/pwww/.htpasswd jerry
    labot esošo
    htpasswd /home/pwww/.htpasswd-users tom


  • sshfs mount

    sshfs root@10.233.10.212:/ /mnt/ssh/


  • Linux disku tūļi

    Disku aktivitāte:
    iotop
    vmstat 1
    iostat 1
    isof
    strance -e trance=open


    strance -e trance=open -p

    Disku informācija:
    hdparm -I /dev/sda

    ……..More


  • Aizvieto tekstu failos kas atrodas vienā direktorijā

    #!/bin/bash
    FILES=/home/john/something/*
    for f in $FILES
    do
    replaceit --input=$f "ko" "ar_ko"
    done

    * nepieciešams uzinstalēt replaceit pakotni


  • Skripts kas failus saspiež un noliek uz FTP servera

    #!/bin/bash
    USERNAME="lietotajvards"
    PASSWORD="parole"
    SERVER="mansserveris.lv"
    MYFILES="/home/user/myfiles"
    ARH="/home/user/temp"
    DOW=$(date +"%A")
    tar cpPzf $ARH/myfiles.tgz $MYFILES
    echo "myfiles ok"
    lftp -u $USERNAME,$PASSWORD -e "cd /$DOW; mput $ARH/*; quit" $SERVER
    rm $ARH/*

    * nepieciešams uzinstalēt lftp pakotni