Get an affordable high quality web, game, VoIP server at

How to remove Xcode4

October 13, 2011 Leave a comment

Today, I was upgrading my Xcode4.1 to Xcode4.2, some how I had to shutdown the Macbook for a while. After I turned on my Macbook again, the Xcode doesn’t let me upgrade again. I had to remove the Xcode completely and reinstall the Xcode4.2. Just in case who will have the same situation as I had and not sure how to remove Xcode4 completely, here is how:

Search “terminal” at the top right corner of your machine, type the following command in the console:

sudo <XcodePath>/Library/uninstall-devtools --mode=all 

<XcodePath> is the path where your Xcode Dev tools installed. It’s usually


So the full command would be:

/Developer/Library/uninstall-devtools --mode=all


Categories: IOS Dev Tags: ,

Adding a local storage repository for ISO images

October 6, 2011 Leave a comment

Adding a local storage repository for ISO images
If you want to upload an ISO image to the server and make it available for use with the installation of a VPS you can do so by creating a local ISO storage repository.
In XenServer 5 this has already been set up for you. You will find an ISO storage repository configured for the /iso_import/images directory. Simply copy your ISO images to that directory and rescan the repository with this command:

xe sr-scan uuid=`xe sr-list | /usr/bin/perl -e \
'while (<STDIN>) { if (/^uuid.* ([^ ]*)$/) { $uuid = $1; } \
if (/name-label \( RW\): ISOs/) { last; } } print "$uuid";'`

Your ISO images should now be available to you in the XenCenter client.
For XenServer 4 you start by creating a directory where you would like to copy your ISO images to (we’ll assume /var/opt/xen/iso_import for this example):

mkdir -p /var/opt/xen/iso_import

Now copy your ISO images to the /var/opt/xen/iso_import directory.
Now create a repository with this command (in this example we’ll name it “ISOs”):

xe sr-create name-label=ISOs type=iso \
device-config:location=/var/opt/xen/iso_import device-config:legacy_mode=true 

Lastly you need to attach the ISO library with this command:

xe-mount-iso-sr /var/opt/xen/iso_import

Your ISO images should now appear in XenCenter.

Categories: Xenserver

Colocation Specs: Bandwidth, server factor, Ip subnets

September 15, 2011 Leave a comment


A 10Mbps connection relates to approximately 3.3 Terabytes of bandwidth monthly.

Burstable connections,  normally measured on the 95th percentile.

To determine estimated monthly bandwidth for your site, first determine the page size for each page of your website, then estimate how many daily pageviews you project for each. Simply multiply to estimate monthly bandwidth forecasted, allowing for some overhead.

Rack Space

1U = 1.75″ of Vertical Rack Space

2U = 3.5″ of Vertical Rack Space

3U = 5.25″ of Vertical Rack Space

4U = 7.00″ of Vertical Rack Space.

IP Subnets

/30…..4 IP’s – 2 useable

/29…..8 IP’s – 6 useable

/28…..16 IP’s

/27…..32 IP’s

/26…..64 IP’s

/25…..128 IP’s

/24…..256 IP’s

/23…..512 IP’s

/22…..1024 IP’s

/21…..2048 IP’s

/20…..4096 IP’s

Categories: Web Dev Tags: , ,

Setup Samba on Ubuntu

September 15, 2011 Leave a comment

1.To install, first open a terminal window and enter the following command:

sudo apt-get install samba smbfs
sudo gedit /etc/samba/smb.conf

2. Find this section in the file:

####### Authentication #######

# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
;  security = user

3. uncomment the “sercurit = user” like this

####### Authentication #######

# “security = user” is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
security = user

5.Lock user in their home directory(You may skip this, if it’s not needed).

   comment = Home Directory
   read only = No
   browseable = No
   valid users = %S

6.Add share dictorey(You may skip this, if it’s not needed):

   comment = Global Share - All Users
   path = /samba/shared
   read only = No
   guest ok = Yes
   public = Yes
   browseable = Yes
   create mask = 0666
   directory mask = 0777

7.Create a User for samba(You can skip this step if you already have the user created in linux)

adduser theUserNameYouWant

8.then we need to run the smbpasswd utility to create a samba password for the user.

sudo smbpasswd -a theUserNameYouCreated

9. Restart your samba service by using following command:

sudo /etc/init.d/smb restart

*** For more detailed reference please visit:

Categories: Linux Tags: ,

How to add an additional hard drive to Xenserver

September 9, 2011 Leave a comment

1. Login the server as root. list all available physical disk with command “fdisk -l”

Here is my output:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 523 4194304 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 523 1045 4194304 83 Linux
/dev/sda3 1045 19457 147899713 8e Linux LVM

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

2. The new drive i need to add to the host is /dev/sdb in my case.
Let’s get the UUID of your xenserver by using this command “xe host-list”
You should see something like this:

uuid ( RO) : 4fd93ca2-2f60-4387-9fb0-b8abc34b7526
name-label ( RW): xenserver-lgsgdjzo
name-description ( RW): Default install of XenServer

3. Create a new XenServer storage repository by using the  one of the following options(Make sure you use your own uuid instead of my):
Option1:create a normal LVHD storage repository. This is by the way the default storage repository type. (The following code should be typed in one line in your terminal)

xe sr-create host-uuid=4fd93ca2-2f60-4387-9fb0-b8abc34b7526
content-type=user type=lvm device-config:device=/dev/sdb 
shared=false name-label="Local storage 2"

Option2:Create a LVHD storage repository with thin provisioning support.(The following code should be typed in one line in your terminal)

xe sr-create host-uuid=4fd93ca2-2f60-4387-9fb0-b8abc34b7526
content-type=user type=lvm device-config:device=/dev/sdbshared=false
name-label="Local storage 2" sm-config:allocation=thin

Option3: Create a EXT storage repository with thin provisioning support and direct access to the vhd files.(The following code should be typed in one line in your terminal)

xe sr-create host-uuid=4fd93ca2-2f60-4387-9fb0-b8abc34b7526
content-type=user type=ext device-config:device=/dev/sdbshared=false
name-label="Local storage 2"

Done !

Categories: Xenserver Tags: ,

Relaying Postfix SMTP via

February 4, 2011 Leave a comment

Install the required packages

sudo aptitude install postfix libsasl2 ca-certificate libsasl2-modules

Configure Postfix

This tutorial will not outline how to configure your postfix server, but we’ll jump directly to the relayhost section.  You’ll want to add the following lines to your /etc/postfix/ file:

relayhost = []:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

The above lines are telling Postfix that you want to relay mail through gmail on a specific port, telling it to authenticate, and where to find the username and password.  The last three lines specify the authentication types supported, where the certificate authority file is and that it should use tls.

Define Username and Password

Next we’ll need to populate the sasl_passwd file.  Create the file /etc/postfix/sasl_passwd with the following contents:

[]:587      (If you have customized domain just replace by @yourdomain)

This file should have restrictive permissions and then needs to be translated into a .db that Postfix will read.

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

At this point you can restart Postfix and it should work, however it will complain about not being able to authenticate the certificate.  To take care of this issue we’ll use the ca-certificate package we installed and tell it where it can validate the certificate.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Go ahead and reload postfix (sudo /etc/init.d/postfix reload) .



Categories: Linux, Web Dev

Using sudo, ssh, rsync on the Official Ubuntu Images for EC2

February 4, 2011 Leave a comment

The official Ubuntu images for EC2 do not allow ssh directly to the root account, but instead provide access through a normal “ubuntu” user account. This practice fits the standard Ubuntu security model available in other environments and, admittedly, can take a bit of getting used to if you are not familiar with it.

This document describes how to work inside this environment using the “ubuntu” user and thesudo utility to execute commands as the root user when necessary.


First, to connect to an instance of an official Ubuntu image for EC2, you need to ssh to it as “ubuntu” instead of as “root”. For example:

ssh -i KEYPAIR.pem ubuntu@HOSTNAME

Note that existing EC2 documentation and tools like the EC2 Console and Elasticfox assume that all EC2 instances accept connections to root, so you’ll have to remember this change.

If you accidentally ssh to root on one of the official Ubuntu images, a short message will be output reminding you to use “ubuntu” instead.


When logged in under the “ubuntu” user, you can run commands as root using the sudocommand. For example:

sudo apt-get update && sudo apt-get upgrade -y

Note that sudo clears the environment variables before running the command. If you need to have them set, then use the sudo -E option.


The official Ubuntu images for EC2 are configured so that no password is required for sudo from the “ubuntu” user. Yes, this sacrifices a bit of security from standard Ubuntu operation, but any published hardcoded password would be more insecure, and randomly assigned passwords quickly become unmanageable when running many instances, in addition to preventing some types of remote automation described below.

Note that this policy does not allow logging in to the “ubuntu” user without a password. The password is disabled for login and not required for sudo. Login is done through the usual EC2 ssh keypair management as described above.

If you wish to increase security in this area, set the ubuntu user password and adjust the/etc/sudoers file.

sudo passwd ubuntu
sudo perl -pi -e 's/^(ubuntu.*)NOPASSWD:(.*)/$1$2/' /etc/sudoers

Make sure you set the password successfully first and remember it. If you change the sudoersfile first, you will be stuck with no root access on that instance.


If you want to switch to a root shell once you are logged in to the “ubuntu” user, simply use the command:

sudo -i

This is generally not recommended as it loses the enhanced logging of commands used as root and you risk accidentally entering commands when you did not intend to use root.


To automate a remote command as root from an external system, connect to “ubuntu” and usesudo:

ssh -i KEYPAIR.pem ubuntu@HOSTNAME 'sudo apt-get install -y apache2'


Now for the trickiest one. Sometimes you want to rsync files from an external system to the EC2 instance and you want the receiving end to be run as root so that it can set file ownerships and permissions correctly.

rsync -Paz --rsh "ssh -i KEYPAIR.pem" --rsync-path "sudo rsync"   LOCALFILES ubuntu@HOSTNAME:REMOTEDIR/

The --rsh option specifies how to connect to the EC2 instance using the correct keypair. The command in the --rsync-path option makes sure rsync is running as root on the receiving end.

The -Paz options are just some of my favorites. They aren’t a key part of this rsync approach.

In order for this method to work, the “ubuntu” user must be able to sudo without a password (which is the default on the official Ubuntu images as described above).


Finally, if you wish to circumvent the Ubuntu security standard and revert to the old practice of allowing ssh and rsync as root, this command will open it up for a new instance of the official Ubuntu images:

ssh -i KEYPAIR.pem ubuntu@HOSTNAME   'sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/'

This is not recommended, but it may be a way to get existing EC2 automation code to continue working until you can upgrade to the sudo practices described above.


For more information on recommended sudo practices in Ubuntu, please refer to:

Categories: Amazon Cloud