linux

warning: Creating default object from empty value in /data/web/1/000/027/003/273448/htdocs/panticz.de/modules/taxonomy/taxonomy.pages.inc on line 33.

BASH

# and
if [ "$foo" == "a" ] && [ "$bar" == "b" ]; then
 
 # or
if [ "$foo" == "x" ] || [ "$bar" == "y" ]; then
 
# both
if ( [ "$a" == "a" ] || [ "$a" == "b" ] ) && ( [ "$b" == "c" ] ); then
 
 
# enable color output systemwide for ls and grep
cat <<EOF>> /etc/profile.d/alias.sh
alias ls='ls --color=auto'
alias grep='grep --color=auto'
EOF
 
# get exitcode prevoius command
${PIPESTATUS[0]}
 
# redirect stdout AND stderr to file
COMMAND &> file.out
 
# sequence
echo {,my-}host{1,{3..5},9,10}
echo $(seq 1 4)
 
# for loop
START=1
END=10
for ((i=START; i<=END; i++)); do
    e

Scripts

# extract audio from video file
IFS=$(echo -en "\n\b")
for i in $(ls /media/${USER}/*/*); do
avconv -i $i -vn -c:a copy /tmp/${i##*/}.mp3
done

# join multiple PDF files
cd /media/*/Linux-Magazin*/pdf
for DIR in $(ls); do
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/tmp/lm2013-${DIR}.pdf ./${DIR}/*.pdf
done

# lm
for i in $(ls *.jpg); do
convert -page A4 -density 72 $i $i.pdf
done

rm /tmp/lm20*.pdf
for x in {01..12}; do
pdftk lm13/c/cover-${x}-*.pdf lm13/pdf/${x}/*.pdf cat output /tmp/lm2013-${x}.pdf
done

Create XEN Zimbra domain (Zimbra Collaboration Suite)

#!/bin/bash
 
wget http://www.panticz.de/sites/default/files/ubuntu-2.6.22-14-xen.i386-kernel.tar.bz2 -P /tmp
tar -xjPf /tmp/ubuntu-2.6.22-14-xen.i386-kernel.tar.bz2
 
DOMAIN_NAME=mx
 
xen-create-image --hostname=$DOMAIN_NAME --ip=192.168.1.231 --gateway=192.168.1.5 --netmask=255.255.255.0 \
--dir=/home/xen --dist=gutsy --mirror=http://archive.ubuntu.com/ubuntu/ --arch=i386 \
--size=8Gb --memory=1Gb --swap=1Gb \
--kernel=/boot/vmlinuz-2.6.22-14-xen.i386 --initrd=/boot/initrd.img-2.6.22-14-xen.i386
 
cp /etc/xen/$DOMAIN_NAME.cfg  /etc/xen/$DOMAIN_NAME.cfg.org
sed -i 's|file:|tap:aio

Send HTML mail from command line (Newsletter)

#!/bin/bash
 
# http://www.panticz.de/Send-email-from-console
 
INPUT=./adr_uniq.txt
CONTENT=./nl_de.html
SUBJECT="YOUR_SUBJECT"
LOG=./nl_de_$(date -I).log
 
# send 
for i in $(cat $INPUT); do
   mail -a 'Content-type: text/html;' -s "$SUBJECT" "$i" < $CONTENT
   echo "$i - $?" | tee -a $LOG
done

Install Ubuntu Hardy from HDD

#!/bin/bash
 
# download netboot image
wget http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/netboot.tar.gz -P /tmp
 
# extract and copy install files
tar xzf /tmp/netboot.tar.gz -C /tmp
mkdir /boot/ubuntu
cp /tmp/ubuntu-installer/amd64/initrd.gz /boot/ubuntu/
cp /tmp/ubuntu-installer/amd64/linux /boot/ubuntu/
 
# create GRUB menu entry
cat <<EOF> /etc/grub.d/49_ubuntu
#!/bin/sh
exec tail -n +4 $0
 
menuentry "Network Ubuntu install" {
    root (hd0,0)
    kernel /boot/ubuntu/linux
    initrd /boot/ubuntu/initrd.gz
}
EOF
chmod 

Gnome

# get settings
gsettings list-recursively | grep -i gedit
gsettings list-recursively org.gnome.settings-daemon.plugins.power
dconf read /org/gnome/settings-daemon/plugins/media-keys/calculator 
 
# unity
setsid unity
dconf dump /org/compiz/
 
# http://askubuntu.com/questions/67355/how-do-i-completely-turn-off-screensaver-and-power-management
# /usr/share/glib-2.0/schemas/org.gnome.desktop.wm.preferences.gschema.xml 
 
dconf watch /
http://askubuntu.com/questions/359593/is-it-possible-to-monitor-dconf-for-changes
 
# reset pannel settings
gconftool-2 --recursive-unset /apps/panel
d

Apache webserver

# list loaded modules
/usr/sbin/apache2ctl -M

# list avaiable modules
apachectl -t -D DUMP_MODULES

# check config
apache2ctl -S

a2dismod status - disable module

apachectl -V

# enable default SSL site
a2ensite default-ssl

# disable default SSL site
a2dissite default-ssl

Enable mod_rewrite module
a2enmod rewrite
/etc/init.d/apache2 force-reload

# /etc/apache2/sites-available/default f
change"AllowOverride None" to "AllowOverride All"
or the directory in which you will use the mod_rewrite module

ImageMagic

montage - create a composite image by combining several separate images

#!/bin/bash

for i in *a.jpg; do
F=${i//a.jpg/}
echo $F
montage -label ${F} -compress "Lossless" -geometry +4+4 ${F}a.jpg ${F}b.jpg ./2/${F}.jpg
done

Perl

Execute command
#!/usr/bin/perl

qx"/usr/bin/mysqldump --host=YOUR_HOST_NAME --password=YOUR_DB_PASS --user=YOUR_DB_USER YOUR_DB_NAME | bzip2 --best > export_db.sql.bz2";

Syndicate content