How to batch rename files in Ubuntu

You can batch rename files in Ubuntu using the “rename” command. It should be installed by default – so no need to apt-get install.

The command is quite simple:

rename s/"SEARCH"/"REPLACE"/g *

For example renaming:

google_marker_green.png
google_marker_blue.png
etc…

To:

map_marker_green.png
map_market_blue.png
etc…

rename s/"google"/"map"/g *

Hope this helps someone.

Networking disconnects with libvirt (kvm) and vm still running on Ubuntu

We’ve had a problem with some of our KVM Virtual machines where the network connection just disappears. The vm is still running but essentially it’s unreachable over the network (just like if you have pulled out the network cable of real computer). Until, I found the fix, I had to connect to the VM using VNC and then reboot it and everything works for a little while again. This happened on both Ubuntu 12.04 and 13.04 machines which and been completely updated.

I found it really hard to diagnose and searched endless for “kvm libvirt networking problem” or “kvm libvirt networking disappeared” or “kvm libvirt networking failure” etc.

However after trial and error, I found that the virtio virtual network driver was to blame. Changing it to the e1000 virtual network driver solved the problems.

So…

virsh edit vm-name

And change…

<interface type='bridge'>
    <mac address='xx:xx:xx:xx:xx:xx'/>
    <source bridge='br0'/>
    <model type='virtio'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

to

<interface type='bridge'>
    <mac address='xx:xx:xx:xx:xx:xx'/>
    <source bridge='br0'/>
    <model type='e1000'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>

Hope this helps someone.