PHP: Disable Xdebug for CLI

In most scenarios you won’t need Xdebug on your CLI. Also it is recommended to disable it if you use Composer . sudo php5dismod -s cli xdebug

February 10, 2015

Twig: Render String as Template

In case your template is not located in a file but in the database Twig allows you to render a string: $twig_env = new Twig_Environment(new Twig_Loader_String); $output = $twig_env->render('This is {{ foo }}', [ 'foo' => 'an ordinary string', ]); // $output now contains: This is an ordinary string

January 19, 2015

shred a hard drive

If you want to destroy all data on a device use the following command. shred is part of the coreutils package. /usr/bin/shred -v -f /dev/sda Data destroyed by shred can’t be restored unless you invest a lot of time and use special equipment. Use with caution. The option -n can be used to increase the amount of iterations (default: 3).

October 7, 2014

git: set new origin

In case the URL of your remote git repository has changed, update your local repository as follows: git remote set-url origin git@server:path/to/repository.git

October 1, 2014

Debian: waiting for root filesystem fails (using software raid)

If your system does not boot up und you’re dropped to an initramfs shell after “waiting for root filesystem” fails – check your mdadm config /etc/mdadm/mdadm.conf Make sure it contains the correct definitions which are available with mdadm --detail --scan Adjust your config and run update-initramfs -u -k all to make the system bootable again.

September 29, 2014

Debian: get around maintenance shell asking for root password

Once in a while it might happen to you that you attempt to boot some Debian machine and some fsck errors occur. Debian will then present you a maintenance shell and ask for your root password. There are two options at this point: Enter your root password or hit CTRL-D to continue. Continuing will not resolve the problem as the fsck error needs to be fixed manually. If you don’t know your root password or you’re just to lazy to type in a 30 character string the following might help....

August 11, 2014

fail2ban: unban IP from iptables

In case an IP gets banned by fail2ban and you want to remove it: The following command gives you an overview of all chains and the banned IPs along with their corresponding number. iptables -L -n --line-numbers To unban an IP use this command with the correct chain and number: iptables -D fail2ban-ssh 2 Another method is the usage of fail2ban-client: fail2ban-client set sasl unbanip IP

April 11, 2014

generate a new self-signed SSL certificate for Virtualmin/Webmin

Virtualmin/Webmin ships with a self-signed SSL certificate. In case you want to generate a new one, here’s how: openssl rsa -in webmin.key -out webmin.pem openssl req -new -key webmin.key -out webmin.csr openssl x509 -req -days 1095 -in webmin.csr -signkey webmin.key -out webmin.crt cat webmin.crt >> webmin.pem cd /etc/webmin/ cp miniserv.pem miniserv.pem.bak cp /root/ssl/webmin.pem miniserv.pem service webmin restart

April 9, 2014

Xen: extend lvm of virtual machine

First: Make sure to shut down the virtual machine or to unmount the disk inside it. Once finished you can start to extend the logical volume on the hypervisor: lvextend -L+400G /dev/vg0/disk e2fsck -f /dev/vg0/disk resize2fs /dev/vg0/disk There might be a chance you need kpartx, growpart (provided by cloud-guest-utils) followed by resize2fs to grow the mounted partition. In case you shut down the virtual machine you may start it again with...

April 4, 2014

git: add manually removed files to index

If you ever manually remove files from a git repository you have to tell git they have been removed and add the files to the index to commit the changes afterwards: for FILE in $(git ls-files --deleted);do git rm $FILE;done

February 24, 2014