Wednesday 17 December 2014

Simple Way of Ordering Error Messages over Multiple Syslog Files


 for file in `ls -lt messages*| awk '{print $9}'`; do echo $file; echo; grep ERROR $file; done  

Tuesday 4 February 2014

Tuesday 7 January 2014

View what the spec file does on an RPM

This can be done using the following command:-

 rpm --scripts -qp rpmname.rpm  

Thursday 2 January 2014

Extend logical volume to occupy the rest of the free space

Check that nothing is locking the partition:-
 lsof /opt/  

Unmount the partition:-
 umount /opt  

Extend the partition:-
 lvextend -l +100%FREE /dev/mapper/vg_root-lv_opt  

Check the filesystem:-
 e2fsck -f /dev/mapper/vg_root-lv_opt  

Resize the filesystem:-
 resize2fs -p /dev/mapper/vg_root-lv_opt  

Check the filesystem:-
 e2fsck -f /dev/mapper/vg_root-lv_opt  
Remount the partition:-
 mount /opt/

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'