How to export/import a XenServer VM from the Command Line

We can list the VM’s by running

xe vm-list

You can export a VM using either the name of the VM or by using the uuid.  The above command list both so you can use which ever one you want.

You will also need to shutdown the VM your going to export.

xe vm-shutdown vm=ubuntu

Export by Name
The name of the VM is”ubuntu”.

xe vm-export vm=ubuntu filename=/backup/ubuntu.xva

Export using uuid

xe vm-export uuid=b24dcd65-5e12-4576-2f39-46ecab9362ab filename=/backup/ubuntu.xva

Importing VM

xe vm-import vm=centos5 filename=/backup/ubuntu.xva

SNMP and Shell Script

First you will need to make sure SNMP is installed.

apt-get install snmpd snmp snmp-mibs-downloader

You’ll need to configure a new snmpd.conf file with

snmpconf

Run through the steps and when your done replace your current snmpd.conf file in /etc/snmp/ with the new one.

Now open up your new snmpd.conf file

vi /etc/snmp/snmpd.conf

and add the following to the bottom of the file.

extend myshscript /path/to/your.sh

Save and close the file and restart the snmpd service.

service snmpd restart

Now we need to find the OID of our new data point.  Do this by running

snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2

It should display something similar to the following.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost .1.3.6.1.4.1.8072.1.3.2
iso.3.6.1.4.1.8072.1.3.2.1.0 = INTEGER: 1
iso.3.6.1.4.1.8072.1.3.2.2.1.2.4.118.111.108.116 = STRING: "/etc/snmp/volt.sh"
iso.3.6.1.4.1.8072.1.3.2.3.1.4.4.118.111.108.116 = INTEGER: 0
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

The OID we are interested in is the one on the last line.  If you run a snmpwalk command with the OID you should get your data point.

root@localhost:/etc/snmp# snmpwalk -v2c -c public localhost 1.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1
iso.3.6.1.4.1.8072.1.3.2.4.1.2.4.118.111.108.116.1 = STRING: "14.3"
root@localhost:/etc/snmp#

All that’s left is to add the OID to your SNMP monitor.  If You run into issues with your SNMP server not monitoring the OID, you might need do what I did in the above command, replace the beginning of the OID “iso.” with a “1”.

 

Basic snmpwalk Commands

A snmpwalk basically allows you to walk out all the SNMP OIDs for a device.  The following command shows all SNMP data that can be acquired on “localhost”.  You can change “localhost” to an ip address or hostname if you want to view SNMP data on a remote machine.

snmpwalk -v 2c -c public localhost

The above command starts an snmpwalk against “localhost”, using SNMP version “2c”, and the community string “public”.  You should change the SNMP version and community string to what ever you have setup on your network.

If you just want to view one OID then you can just append that OID to the end of the above command.

snmpwalk -v 2c -c public 192.168.1.58 1.2.840.10036.3.1.2.1.4

How to set a Static ip Address in OS X from Command Line

You can set a static ip address in OS X with the following command. Replace en0 with the appropriate interface.

sudo ipconfig set en0 INFORM 192.168.10.12

The default ethernet interface on a Mac is usually en0. You can run ifconfig to view all the interfaces available on the machine.

The ip address will last until you reboot.

How to Reset an OS X Password

You first need to boot your Mac into single user mode by booting it up while holding down the “command+s” keys.

Once your in Single User Mode type in

mount -uw /

That will mount your Mac hard drive. Now run

launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

and now you can change the password.  Replace “username” and “password” with the username for the user and the new password.

dscl . passwd /Users/username password

Now you can reboot the machine

reboot

and log in with the new password.

How to Install an OS X .pkg file from Command Line

The following command installs the .pkg to the local hard disk.

installer -pkg /Users/username/Desktop/package.pkg -target LocalSystem

You can also replace “LocalSystem with a “/” they both do the same thing.

If you want to install the package on a different disk you can change the -target to the drives path.

installer -pkg package.pkg -target "/Volumes/Macintosh HD2"

You can find more about the command by typing “man installer” in the terminal.

How to Allow Ping Through Windows Firewall

Open up Windows Firewall with Advanced Security.

You can do this by going to
Control Panel –> System and security –> Windows Firewall –> Advanced settings

Or hit the Windows key and type in firewall and hit enter

Select Inbound rules and then add a New Rule.  On the New Inbound Rule Wizard select Custom for the type of rule and hit next.  Allow All programs and then hit next again.  Select ICMPv4 as the Protocol type and if you want you can specify the ICMP types by clicking on the Customize button.  Finish running through the wizard give it a name etc. and click Finish when your done.

 

How to reset Minecraft Demo timer without resetting the World – MacOS

Open up Finder and hit the Shift, Command, and “G” key simultaneously and then type in ~/Library/Application Support/minecraft/saves/Demo_World and hit return.

This should put you in your Demo World minecraft directory.

Now delete the “level.dat” and “level.dat_old” files and restart minecraft.  Your time should now be reset… As well as your Objectives.

Reset Root Password for FreeBSD

Boot up FreeBSD, when you get to the FreeBSD boot menu select “Boot FreeBSD in single user mode”

When you get to the following prompt hit enter.

When prompted Enter full pathname of shell or RETURN for /bin/sh:

You will now be booted in single user mode.

Run the following commands to mount the root drive as read and write.

mount -u /
mount -a

Now reset the root password with passwd

passwd root

Your now finished. You can type in “exit” to continue booting, or you can just reboot.

How to Create a LVM Logical Volume in Linux

First we need to create the Physical Volume.  Change “/dev/sda2” to your drive.

pvcreate /dev/sda2

Next we create the Volume Group.  You can change “VGname” to something else if you so desire.

vgcreate VGname /dev/sda2

And finally, create the Logical Volume.  The Logical Volume’s name will be home.  Change as needed.

lvcreate -l %100FREE -n home VGname

The above command will create a Logical Volume that uses all the free space avaliable in the Volume Group.  If you want the Logical Volume to be a specific size,  change “-l 100%FREE” to “-L 60G”.  Where “60G” is the size in GB.
Example:

lvcreate -L 60G -n home VGname

Your Logical Volume should be setup now.  You can list all your Logical Volumes with

lvdisplay

You may need to format the new logical volume to mount it.  Replace VGname and LVname for the Volume Group name and the Logical Volume name.

mkfs.ext4 /dev/VGname/LVname

Mount it with

mount /dev/VGname/LVname /mount/point