Saturday, 28 September 2013

Migrating VMs from Redhat to Ubuntu

Recently I have installed Kubuntu onto my PC and had some Virtual Machines that I had used on a Centos machine under Virt-Manager/KVM that I needed to use on the Kubuntu system. I thought this would be a simple enough process but ran into some problems.

When trying to start up VMs in Virt-Manager on Ubuntu I got the following message:-

 error: Failed to start domain blackhat.example.net supported
 machines are 
...

To fix this I initially created a new VM to see what types it supported it does support Redhat VMs. Once this was created I viewed the XML for the image with the following command:-

 virsh dumpxml test

test being the name of the new VM I had created. The following line was relevant:-

 <type arch='x86_64' machine='pc-1.0'>hvm</type>  

In my other VM I saw the following:-

 <type arch='x86_64' machine='rhel6.2.0'>hvm</type>  

So the problem is machine='rhel6.2.0' to change this run the following command:-

 virsh edit blackhat.example.net  

Then change 'rhel6.2.0' to 'pc-1.0' it should then boot

Monday, 9 September 2013

ssh in a loop

Using ssh in a loop will break the loop to fix this use the -n flag, i.e:-

while read server
do
   echo $server
   ssh -n $server "ls -l /etc/rc.modules"
   echo
done < servers

Tuesday, 3 September 2013

Show vendor when searching through installed RPMs

This is done using the %{VENDOR} tag. For example:-

rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE} %{VENDOR}\n'

Monday, 2 September 2013

Highlight all occurences of selected word in vi

To do this:-

:set hlsearch

To undo this:-

:nohlsearch

Show line numbers in vi

:set number

Rebuild RPM DB

This may need to be done in instances where simple commands such as rpm -qa hang. Steps:-
  1. Kill all rpm and yum processes
  2. yum clean all
  3. rm -f /var/lib/rpm/__db*
  4. rpm -v --rebuilddb
  5. yum makecache

Tuesday, 23 July 2013

Mac Tips and Tricks

Recently I have been using a Macbook Pro for work (OS X 10.8.3), it's good but I have come across a few things that I am not used to and have discovered ways to fix them.  

Using Mac with regular UK keyboard
There are several problems:-
- Hash key in the wrong place
- @ key in the wrong place
- " key in the wrong place
- | symbol in the wrong place
- ~ key in the wrong place
- Home and End keys don't work
- Copy and paste are apple + c and apple + v

With regards to the standard keys there are several keyboard layouts you can download and use, the best of which I can find is the British (PC 105 alt) downloaded from the following location:-

http://liyang.hu/osx-british.xhtml

With regards to home and end keys see the following:-

http://lifehacker.com/225873/mac-switchers-tip--remap-the-home-and-end-keys

However the home and end keys still won't work in firefox! For this install the KeyFixer add-on:-

https://addons.mozilla.org/en-US/firefox/addon/keyfixer/?src=search

With regards to copy and paste keys, you can go to System Preferences > Keyboard > Keyboard Shortcuts and set Application Keyboard Shortcuts > All Applications > Add Shortcut

- Copy ^C
- Undo ^Z
- Cut ^X
- Paste ^V  

Scroll doesn't work the same way

This is an easy one to change. Go to System Preferences > Trackpad > Scroll and Zoom > Scroll Direction: natural - untick this.  

Useful Software to install

iTerm2 - pretty similar to terminator in linux (which can also be installed for Mac):-

http://www.iterm2.com/#/section/home

csshX - cluster ssh for Mac:-

http://code.google.com/p/csshx/