Twitter

From now on all my posts will be published on Twitter. So you can follow me and never miss any updates

Write a comment

2013-10-08 13:50:55

Find files by date

An easy way to search for files within a daterange:

$ touch --date "1970-01-01" /tmp/start
$ touch --date "2038-01-19" /tmp/end
$ find /location -newer /tmp/start -not -newer /tmp/end

Write a comment

2013-10-01 12:28:25

Multiple SSH Keys

Sometimes I need to generate passwordless authentication via ssh. So here is a little tutorial:

# On local machine:
$ ssh-keygen -t rsa -f ~/.ssh/id_rsa_remotemachine
$ scp ~/.ssh/id_rsa_remotemachine.pub user@remotemachine:.ssh/
$ echo Host machine >> ~/.ssh/config
$ echo IdentityFile ~/.ssh/id_rsa_remotemachine >> ~/.ssh/config
$ echo User user >> ~/.ssh/config

# On remote machine
$ cat ~/.ssh/id_rsa_remotemachine.pub >> ~/.ssh/authorized_keys

Now login should work with "ssh remotemachine".

Write a comment

2013-10-01 11:39:05

Downloads

There was a problem with my downloads. Fixed it and now it should work again

Write a comment

2013-09-29 18:32:43

Calculate with zsh

An easy calculator for the z-shell. Insert into ~/.zshenv:

zcalc () { print $(( ans = ${1:-ans} )) }

Some examples:

% zcalc 5/2 # Division with integer
2
% zcalc 5.0/2 # Division with floating point
2.5
% zcalc "5*2"
10
% zcalc 5%2 # Modulo Operations
1

Write a comment

2013-08-15 15:05:47

Comments

I've reimplemented the comments section. The CAPTCHA must now be entered together with the comment and you will no more redirected to another page.

Write a comment

2013-06-13 14:01:28

systemd, netctl, ifplugd and bridge

Today I attended to automatic connection on wireless and wired interface. The wireless interface was no problem on Arch Linux. Just install wpa_actiond and enable netctl-auto@.service. More headache on the bridged interface:

ifplugd only recognizes interfaces listed in /proc/net/dev, where br0 isn't listed until it is started by netctl. So after a bit research I found /etc/ifplugd/netctl.action which is called by ifplugd in conjunction with netctl. A typical call is "/etc/ifplugd/netctl.action eth0 up". But eth0 isn't in one of my netctl profiles as interface and br0 is no device in which a cable is ever plugged in..

So I've had to options: 1. Giving up my bridge, 2. Adjusting netctl.action. Giving up my bridge would lead to unusable VMs, ergo only one option left:

Replace the test against the interface with the bridge interface and the test against the connection with "bridge". This will always use your bridge profile and nothing else anymore. In other words:

#Replace
[[ "$Interface" == "$1" && "$Connection" == "ethernet" ]] || continue
#with
[[ "$Interface" == "br0" && "$Connection" == "bridge" ]] || continue

After changing netctl.action you just need to enable netctl-ifplugd@eth0.service and ifplugd@eth0.service (replace eth0 with your interface).

Attention: I use only one bridge profile with a static IP. Whenever I need a dynamic IP I use my WiFi. It is possible that this solution my not work, if you use other profiles as well...

Write a comment

2013-04-18 21:53:54

Convert Xen xva to vhd

Sometimes I need to convert a xen xva image to a vhd image for VirtualBox. So here is a quick howto:

qemu-img convert -O raw input_file.xva output.raw
VBoxManage convertfromraw input_file.raw output_file.vhd --format VHD

Write a comment

2013-04-03 12:01:31

find | xargs

Today cron doesn't want to regexp my "cp [a-Z]* ...". Even if i set SHELL=/bin/bash in the crontab it got the error "cp: cannont stat [a-Z]*: No such file or directory". Manually on the shell there is no problem with regexp (it's locales fault; cron uses the POSIX locale and here I should use [a-zA-Z] as regexp). So I tried find in combination with xargs:

find /dir -print0 -type f | xargs cp -t /target/dir

The commandline switch -t makes it easier to use xargs with cp and even mv.

Write a comment

2013-03-26 09:24:53

udev rules

Looks like Linux 3.8 has a stupid bug. The e1000e driver for Intel NICs does not work correctly (ref. here). In short: The powersaving prevents the NIC from comming up correctly. So I wrote a udev rule to always power on my NIC. In fact there are only a little chances I won't need it:

SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{subsystem_device}=="0x21f3", ATTR{device}=="0x1502" ATTR{power/control}="on"

Compare vendor, subsystem_device and device with your own configuration. Either with udevadm(8) or with udevinfo(8).


Another problem with powersaving was my mouse. Everytime I didn't plugged in my powercord, I had a very stuttering cursor. So I wrote another udev rule:

SUBSYSTEM=="usb", ATTR{idVendor}=="1d6b", ATTR{idProduct}=="0002",  ATTR{power/control}="on"

It is nearly the same except of the "search attributes".

Write a comment

2013-03-17 17:08:23