Categories
Tech

Set Static IP Address in Centos

Using your favourite text editor (vi) open the default network configuration for the network adapter you wish to configure. I wish to assign a static IP to the default ethernet adapter (eth0). You will need superuser privileges so remember to use sudo

sudo vi /etc/systemconfig/network-scripts/ifcfg-eth0

For the purpose of this post I will be using the following typical network configuration.

  • Host IP Address: 192.168.0.100
  • Netmask: 255.255.255.0
  • Gateway: 192.168.0.1

Update the following highlighted fields with your relevant network settings.

DEVICE="eth0"
BOOTPROTO="static"
HWADDR="00:11:22:33:44:55" 
NM_CONTROLLED="yes"
ONBOOT="yes"
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
TYPE="Ethernet"
UUID="9a6aae04-2b82-4986-951a-1081c0012345"
Categories
Tech

Reset Linux Root Password In Xen Paravirtualised Virtual Machine

This can be used to reset forgotten root passwords in paravirtualised VM’s running on the Xen hypervisor.

1. Identify target VM name.

virsh list --all

2. Shutdown the target VM.

virsh shutdown vm-name-goes-here

3. Start the VM back up again in console mode.

xm create -c vm-name-goes-here

4. Quickly stop the boot process on the grub menu and hit the a key on the default kernel. Once the kernel parameters appear, append the number 1 to the end of the line. Then hit enter to continue with the VM boot.

5. You should then be dropped into a single user mode console, allowing you to reset the password as you would on a physical host.

6. Enter this command to change the root password, you have to enter the new password twice when prompted onscreen.

passwd

7. Reboot

reboot
Categories
Tech

Install Twisted (Python) on CentOS 6

Make sure the current system is up-to date

yum update

Install the necessary packages required to satisfy Twisted’s dependancies.

yum install wget python-devel python-zope-interface

Also install the Development Tools

yum group install “Development Tools”

Download the Twisted Framework (example location: ~/src)

wget http://twistedmatrix.com/Releases/Twisted/12.1/Twisted-12.1.0.tar.bz2

Extract files and install

tar jxvf Twisted-12.1.0.tar.bz2
cd Twisted-12.1.0.tar.bz2
python setup.py install

Test the installation was successful by creating a Python test file.

nano twistedTest.py

Insert the following lines:

import twisted
import twisted.web

Save the file

Ctrl-X (Enter filename when prompted)

Execute the file with hopefully no errors

python twistedTest.py

Categories
Tech

Common Linux Commands

This will be an on-going post that I will use to keep track of my most commonly used commands.
Tested on Centos 6.3.

Linux Misc

List users

cat /etc/passwd

List groups

cat /etc/group

View free memory

free -m

View disk space usage

df -h

Git

Init new remote repo

git init –bare

Clone existing repo using HTTP

git clone http://repourl.com/path/to/repo

Clone existing repo using SSH on non-standard port

git clone ssh://user@repourl.com:8888/path/to/repo

Xen using LibVirt

List running Virtual Machines on Node

virsh list

List all Virtual Machines on Node

virsh list –all

Categories
Tech

Convert Subversion Repo to Git

Create a local empty SVN repo.

svnadmin create /path/to/repo

In the newly created repo cd into hooks/ and create new file named pre-revprop-change and enter the following.

#!/bin/bash

Remember to make the newly created file executable.

chmod +x hooks/pre-revprop-change

Initialise the local repo to point to the SVN.

svnsync init file:///path/to/local/repo https://path/to/online/repo/svn

Sync the two together.

svnsync sync file:///path/to/local/repo

Import the local SVN repo to a newly created Git repo.

git svn clone file:///path/to/local/repo projectname

Create a new Git –bare remote repo and add a remote link to the local repo.

git remote add origin https://githost.com/project.git

Push the local repo to the remote.

git push origin master

Bish bosh job done! Your now free of the tiresome Subversion 😀