Sunday, April 26, 2009

Repair a broken Linux boot sector

Dual booting Linux and Windows can cause boot sector problems because the Linux boot loader GRUB, plays nicely with Windows but Windows, especially XP, does not like to play with Linux. Of course, reinstalling an operating system will fix this but repairing the boot sector is a much nicer solution.

I am currently dual booting Windows XP and Ubuntu on my desktop and lucky me, I reinstalled Windows and lost the ability to boot into Ubuntu. In the likely chance that this will eventually happen to you, here's how you do it.

Insert your Ubuntu live installation CD and start a new Terminal session. Type this:
sudo grub
This starts the GRUB console. The prompt should change to look like this: "grub> ". Now type:
find /boot/grub/stage1
This should return something that looks like this: "(hd0,0)". Remember what the numbers are. In my case both were zeros but it could be different for you. Now type these commands:
root (hd0,0)
setup (hd0)
Make sure the values you enter correspond to the response you received earlier. That should fix your booting problems. Now just restart and you should be able to boot into your Linux installation.

Refresh your IP in Linux

Almost everyone has, at one time or another, needed to refresh their IP address. In operating systems with a nice GUI this is usually the simple work of clicking a button. It turns out to be not much harder in Linux server environments devoid of a GUI. Run these commands:
sudo dhclient -r
sudo dhclient
The first command will release the current IP address. The second command will fetch the new IP address from the DHCP server.

Nice and easy.

Grep is a Beautiful Tool

Grep is a fantastic Unix command line tool. It is used to print out strings of text that match a particular pattern specified by the user. It is especially useful when combined with other commands and piping the output into the grep tool.

For example, I am working on a project and today I was faced with a log file that was over 5000 lines. However, only about 1500 of those lines contained information that was useful. All the rest of the lines referenced a connection being created. Lucky for me, all of those lines contained the string "Got an IP Packet" or "Got an ICMP Packet." By using grep, I was able to quickly and easily create a second log file containing only the useful information. Here's how I did it:
cat log.txt | grep -v "Got an " > log-trim.txt
The cat command will print out the contents of a file to the terminal, in this case that file is log.txt. That vertical bar is the symbol for pipe, which will send the results of the command to the left of it to the command on its right. In this case, that means it took the results of the cat command and instead of printing it to the console it send the results to grep. Grep will ordinarily read through a chunk of text from beginning to end and print out every line that contains the specified string somewhere in that line. The -v option reverses that behavior so it will print every line except for those containing the specified string. I only want the lines that do not contain the string "Got an " anywhere in them. Finally, the > symbol says to send the results of the grep command to a file instead of displaying the results at the Terminal.

Now I have a log file of just over 1500 lines instead of one with well over 5000 lines, most of which are useless to me.

The title of this post comes from the blog of programmer Eric Wendelin. Here is a link to his post on grep.

Friday, April 24, 2009

Compute hashes in Linux and OS X

Hashes are used to verify the integrity of a file. A hash is a one-way algorithm designed such that each and every file has its own unique hash. If a small change is made to a file the hash will look vastly different. They are used to verify that a file has not been tampered with. They are often used in conjunction with files to be downloaded. The server hosting a file will have a hash of that file posted so that when someone downloads it that person can compute their own hash of the file and compare it to the one available on the server.

Linux, OS X, and most *nix variants come with tools built in for computing file hashes. By using Cygwin in Windows environments these tools are available as well. The syntax looks like this:
openssl dgst -[hash] [file]
The hash algorithms I tend to see most often are SHA1 and MD5. To compute either of these with a file called "specification.txt," the syntax would look like this:
openssl dgst -md5 specification.txt
openssl dgst -sha1 specification.txt
Some other hashes available using this tool are MD2, MD4, RMD160, and SHA.

Hashes, however, are not perfect. The idea with them is that no one should be able to reverse the algorithm and determine what a file looks like from its hash. MD5, for example, has a vulnerability where a file can be modified from its original version and and still provide the same hash output. A proposed solution to this is to use the results of multiple hash functions for files.

Thursday, April 23, 2009

Check your IP address in Linux or OS X

Curious about what you IP address is on your Linux or OS X machine? Type this at the Terminal:
Some Linux distros, like CentOS, don't have this command as a part of the PATH environment variable so type this instead:
You will see a lot of information after running this command. The line or lines you are looking for begin with the letters "en" and will be followed by a number. The line below this that begins with "inet" has your IP address. If you are on a home network it probably looks something like this: 192.168.x.x, where the x's are replaced with numbers. On my laptop I have a ton of information that gets dumped to the console when I run this command because of all the virtual machines I have so I made a shortcut. I added this line to my .bashrc file:
alias ip='ifconfig en0|grep "inet ";ifconfig en1|grep "inet " '
My laptop has two network interfaces that I care about, "en0" is my wired ethernet and "en1" is my wireless. All I have to do is type "ip" at the Terminal and just that line with the IP address in it for each network adapter and only if it is connected. So I I am using just my wireless and I run this command then I will only get the line corresponding to my wireless IP address but if I am using my wireless and wired network adapters simultaneously and I run this command then I will see both IP addresses.

Your system may be a bit different depending upon how many network adapters you have. My desktop, for example, has three wired ethernet adapters in it so for it the alias line looks like this:
alias ip='ifconfig en0|grep "inet ";ifconfig en1|grep "inet ";ifconfig en2|grep "inet " '

RM replacement using TrashCan in Ubuntu

When using a GUI we have the luxury or a Trash Can when we delete the wrong thing by accident. With a CLI, there is no such luxury when using the rm command. So I made one. It works by adding the following lines of code to your ~/.bashrc file and then reload your Terminal session. It works by typing "del [filename]". This moves the file to the Trash Can for you to delete later at your convenience and it supports restoring the file back to its original location using the GUI "Restore" option.
I have tested this on Ubuntu 8.10 and 9.04 desktop editions.

function del {
mv $1 ~/.local/share/Trash/files
touch ~/.local/share/Trash/info/$1.trashinfo
echo "[Trash Info]" >> ~/.local/share/Trash/info/$1.trashinfo
echo "Path=$PWD/$1" >> ~/.local/share/Trash/info/$1.trashinfo
DATE=`date "+%Y-%m-%dT%T"`
echo "DeletionDate=$DATE" >> ~/.local/share/Trash/info/$1.trashinfo

Determine your Ubuntu release version

Want to check which version of Ubuntu you are running? Run this command at the Terminal:
lsb_release -a
This will display the contents of /etc/lsb-release in a nice and easy to read format. The information contained in this file is all the pertinent version information including the release number and codename.

Monitor your bandwidth in Linux with IPTraf

I found a great little program for monitoring bandwidth usage on a Linux computer from the console. Its called IPTraf. This little tool is ideal to see what is hogging up all the bandwidth because it has a feature to monitor bandwidth by port. By default it only scans up to port 1024 but you can add additional ones beyond that if you'd like.

To install in Ubuntu:
sudo aptitude install iptraf
For other distros check out the download page on the website. The program requires administrator powers to run.

Transmission-daemon 1.52 update

Well the good folks who develop transmission have pushed out an update, 1.52, that seemingly breaks the remote program and won't let it talk to the daemon. In fact it still works, they have just added a new layer of security that was not very well documented. All of the setup and commands work just like they did according to this post with one new change. You now are required to provide authentication in order to get the remote to communicate with the daemon. Here is the syntax:
transmission-remote --auth=transmission:transmission
This is the default setting. You can issue commands to the daemon by adding additional options to the end of that command. You can change this default user name and password with this command:
transmission-daemon -u [username] -v [password]
Or, you can disable this and not require authentication with this command:
transmission-daemon -T
This should work, although it unfortunately did not on my system. If you want to keep from having to enter credentials each time you can create an alias in your .bashrc file so it will be entered for you automatically. Here's how to do that:
echo "alias t='transmission-remote --auth=transmission:transmission'" >> ~/.bashrc
This will create an alias for the remote program so that all you will need to type is the letter t followed by any options and the system will automatically insert the part you see above in single quotes.

Another notable update to Transmission is that there is now a startup script located at /etc/init.d/transmission-daemon so you can easily start, stop, and restart the daemon.

Saturday, April 18, 2009

Enable repositories in OS X with MacPorts

Linux has a great feature in that you can install software packages via repositories; you never have to surf the web searching for the installer to download, just enter a command at the Terminal and the installation is handled for you. Mac OS X does not include this functionality out of the box but can be enabled by installing MacPorts. MacPorts is a free and open source command line utility installed through an OS X .pkg file.

The installer will add the necessary environment variables to ~/.profile so that you can use it at the Terminal. However, if you are using a .bash_profile or .bashrc file the system will never see ~/.profile so you will need to either link to that file or add these lines to the file that holds your customizations:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export MANPATH=/opt/local/share/man:$MANPATH
Open a new Terminal session and you will now be able to use MacPorts. You can access the MacPorts interface by using the port command. To search for a specific package, type:
port search [package name]
Install a package:
sudo port install [package]
Uninstall a package:
port uninstall [package]
List all installed packages:
port installed
Update MacPorts and refresh repository listing:
sudo port selfupdate
Upgrade a specific package:
sudo port upgrade [package]
Upgrade all packages:
sudo port upgrade outdated
Clean up temporary files created when installing packages:
sudo port clean --all
Full documentation is available here and a full list of packages is available here.

Convert Linux binaries with Alien

In Windows, installation packages generally come with either a .exe or .msi file extension. In Mac OS X, they come as either .app, .pkg or .mpkg. In Linux, most software packages you'll want to install are probably available in a repository. There are some software packages that are only available in source or binary form and are not found in a repository. The source packages get compiled at your local machine and installed. The binaries, however, are built specific to a distribution. For example, the most common ones seen are .rpm, for distributions like RHEL, Fedora, and CentOS or .deb, for distributions like Debian, Ubuntu, and Linux Mint.

But suppose there is a package you want to install available in binary form only as an rpm but you run Ubuntu? There is a tool called alien that will convert binaries into different formats. In Ubuntu, you can install it by typing:
sudo aptitude install alien
To convert a package binary to .deb:
sudo alien -d [package binary]
Converting to .deb is the default behavior so the -d flag is optional.

Convert to .rpm:
sudo alien -r [package binary]
Convert to .tgz:
sudo alien -t [package binary]
Convert, auto install, and delete the new binary when finished:
sudo alien -i [package binary]
Once you have converted a package, you can install it in Debian or Ubuntu with:
sudo dpkg -i [package].deb
Or in RPM based distros with:
sudo rpm -i [package].rpm

Thursday, April 16, 2009

Windows Remote Desktop from any system

Microsoft Windows is far from a perfect operating system, in my opinion, but there are some things about it that are really good. One of the features of Windows that Microsoft truly did a fantastic job on is Remote Desktop. The server is built into XP Professional and Vista Business, Corporate, and Ultimate. There is a client built into all versions of XP and Vista, one is also available for OS X and there are several for Linux.

This feature uses a protocol called rdp and is the best way I have found to remote manage Windows machines. Remote Desktop provided full access to the desktop on remote machine. It will log the user in if he is not already logged in on that machine, meaning that the server is active even when no one is logged in on the computer. This I like much more than other remote access tools like VNC, because if the user is not logged in you are out of luck.

Using Remote Desktop you log into the remote machine using the credentials of an existing user on that computer. All connections between the client and server are encrypted. Newer versions use 128-bit RC4 encryption while older versions will use weaker encryption.

Windows XP and Vista each support only a single user at the computer at a time, so Remote Desktop will kick off any other users currently at that computer. This includes anyone physically sitting at the computer. Windows Server versions can allow for more users but that gets into a mess of licensing issues. Whenever connect Windows locks the session locally so no one can see what you are doing unless they are looking over your shoulder. When you terminate your connection the server remains locked until someone with appropriate credentials comes along and unlocks it.

In Windows XP Pro, you can enable Remote Desktop access by right clicking on My Computer and going to Properties. Click the Remote tab and check the box that says "Allow users to connect remotely to this computer."

In Windows Vista Business, Corporate, or Ultimate, you can enable Remote Desktop access by right clicking on Computer and going to Properties. Click on the Remote tab and click one of the radio buttons that starts with "Allow connections." If you will only be accessing the computer from Windows clients running the latest version of Remote Desktop Client, you can click the bottom one. If you intend to access the computer from a Linux computer, you should probably click the middle one.

On Windows, the Remote Desktop Client is located at Start>All Programs>Accessories>Communications>Remote Desktop Client.

On Macs, there is a Remote Desktop client available from Microsoft here. I have been using it for a while and its pretty good. No real complaints about it here.

For Linux, there are a number of client available. Ubuntu comes with one preinstalled called Terminal Server Client. You can find it at Applications>Internet>Terminal Server Client.

Curiously, Linux Mint does not come with this program preinstalled. To install it, type this at the Terminal:
sudo aptitude install tsclient
Now it will appear at the same location as in Ubuntu.

Sync Google Calendar with Outlook

Google Calendar is a fantastic online calendar service I have been using for years. Its available from anywhere you have web access and if you work on multiple computers, its a serious time saver. For Windows users, especially in the corporate world, chances are good that you are using Outlook to handle your calendar. Through the use of a little program created by Google, you can import all of your Google Calendar events into Outlook and sync changes between them.

A word of note: this will work for systems running Microsoft Windows XP and Vista, with Outlook 2003 and 2007. I set mine up using Windows XP and Outlook 2007.

The first things to do, obviously, is setup a Google Calendar account (log in here) and install Outlook. Once you have that taken care of, download Google Calendar Sync. Close Outlook if its open and then run the program you just downloaded. When the installer finishes, the preferences menu will appear for the program. Enter your account information, choose what kind of access you want and the update interval. I want 2-way access to my account so changes made though Outlook or the web interface will be reflected in the other location. There is also the option for 1-way syncing, either way. The default update interval is for every two hours, which I think is probably too slow, but that's up to you.

Now Google Calendar Sync, which lives in your system tray, will start importing your calendar events. You can view its status by hovering your mouse cursor over the icon. When it finishes, you can open up Outlook and you should see all of your events from your Google Calendar. You can change the preferences and start/stop syncing by right clicking on the icon in the system tray.

If you decide to stop using your Google Calendar or for some reason uninstall Google Calendar Sync, all of your events will still be in Outlook. For more information on Google Calendar Sync, check out its homepage here.

Tuesday, April 14, 2009

Manage users in Ubuntu

Ubuntu includes a nice graphical tool for adding and managing users. This is also possible through the use of the command line. This is the only method for servers without a GUI installed. Ubuntu has two ways to add a user, one walks you through the process and the other is a bit more basic. Here's how they work:
sudo adduser [name]
This will setup a new user named [name] with the default settings, including a home directory located at /home/[name]. After setting this up, you will be prompted to enter a password for the new user. The other way is more inline with standard *nix commands:
sudo useradd -m -s /bin/bash [name]
sudo passwd [name]
The -m flag of the useradd command creates the home directory and the -s flag specifies the login shell to use. If you leave this off, the shell it will use is /bin/sh. Instead of using the passwd command to set the password for the user, you could add the -p flag to the useradd command and specify the password to be used then. This, however, means that the password will be written in clear text for anyone looking over your shoulder to see and it is not displayed with the passwd command.

Users can be removed using this command:
sudo userdel -rf [name]
Using the -rf flags will force the removal of the home directory. If you want to retain the files contained there, leave this off.

In Ubuntu, the first user created upon installation is automatically added to the admin group with access to sudo power. Subsequently added users will not be in this group and so will not have sudo power. If you want your other users to be limited users, this is great. If you want to have another user with administrator power, use this command:
sudo usermod -aG admin [name]
This will append admin to the list of a user's groups. The next time this user logs in they will receive a notification of how to use the sudo command. There are other uses for the usermod command. The -s flag, for example, will change the user's login shell.

For more details on these commands, check out the manual pages:
man adduser
man useradd
man userdel
man usermod

Sunday, April 5, 2009

Setup an encrypted private directory in Ubuntu/Linux Mint

Starting with the release of Intrpeid Ibex, Ubuntu has supported having an encrypted private directory in the home directory with minimal setup. I did this on Linux Mint and it works exactly the same way on Ubuntu, but only version 8.10 and later and version 6 or later of Mint. To install this feature, run these two commands at the Terminal:
sudo aptitude install ecryptfs-utils
During the setup you will have the option to specify a recovery key or have one set for you. This is used if your operating system gets hosed and you need to recover the data contained in the encrypted directory. After that, log out and log back in. You will see a new directory in your home folder called Private. Everything stored in this folder is encrypted.

The way it works is that an encrypted image file is created. When you log in, this image is mounted to ~/Private and data is encrypted and decrypted on the fly when you read and write to that directory. The really great thing about this is that the encrypted image gets resized dynamically as data is added and removed. It is seamlessly integrated into the system.

For better security, you can move data files for your programs into this directory and replace them with symbolic links. For example, if you wanted to move your SSH data, which is located at ~/.ssh, you would enter these commands at the Terminal:
mv ~/.ssh ~/Private
ln -s ~/Private/.ssh ~/
This should work with any program you have that stores files in your home directory. The key thing though, is to make sure the program is not running when you move the files.

If you decide not to use this encrypted directory and want to remove it, run these commands:
rm -rf ~/Private ~/.Private ~/.ecryptfs
For more information on this topic, including how to recover the data in this directory, check out this page:

Linux Mint Desktop configuration

This weekend I decided to install Linux Mint on my desktop. Linux Mint is a distribution derived from Ubuntu, which is in turn derived from Debian. While Ubuntu already provides a rich and easy to use desktop environment, Linux Mint takes this and makes it a bit more usable out of the box by including some additional drivers and propriety code, like Flash. Mint uses all of the regular Ubuntu repositories and is compatible with Ubuntu specific binaries. In addition, the people at Mint added some of their own customization and there are some extra tools not present in Ubuntu.

Ubuntu releases a new version every 6 months and Linux Mint releases follow the Ubuntu release by a month or two. The current Ubuntu release is 8.10 (aka Intrepid Ibex) and the corresponding release of Linux Mint is 6 (aka Felicia). Also like Ubuntu, there are seperate 32 and 64 bit versions, and you can get it with the default Gnome or KDE or XFCE if you want. I installed Linux Mint 6 Gnome.

The installation process is very similar to that of Ubuntu. When you log in for the first time you are given the option to enable the Root account, which is by default deactivated in Ubuntu. One of the first things to do with any new installation is get it up to date with all the current patches. This works exactly like it does in Ubuntu:
sudo aptitude update
sudo aptitude full-upgrade
There was a problem I an into early on, which was a kernal mount error when using the default kernal. Mint comes with two options to use for the kernal, 2.6.27-11 and 2.6.27-7. By default, it uses the former, but when I kept getting the same error, I switched to the latter and everything now works great. Both kernals are available to choose from at the GRUB boot screen. The way to change the default option is to edit the config file located at "/boot/grub/menu.lst".

Inside this file, at the bottom, all of the boot options are listed. The default is the the first one listed, which has an index number of 0. The next has an index of 1, followed by 2, and so on. To change which is the default boot option change the integer number on the line that starts with the word "default". It should be near the top. Give the system a reboot to check that it works.

All of the appropriate drivers were automatically selected except for two, graphics and sound. I have an Nvidia graphics card in my desktop and Nvidia does not have open source drivers. Because of this, Mint selects an open source driver that provided significantly reduced functionality by default, but the system tells you there is another driver available. If not, this can be selected by going to System>Administration>Hardware Drivers. I selected the recommended Nvida restricted driver and upon reboot my graphics worked perfectly.

My desktop has a Creative sound card. Creative does provide any binary Linux drivers my sound card, but they do provide source code. Download this and entract the contained folder of code from the tarball. Using Terminal, navigate into that folder and enter these commands:
sudo make
sudo make install
This compiles and installs the source code. When I rebooted, my sound worked. Mint includes a bunch of software just like Ubuntu, but there are some additional things I wanted to install:
avant-window-navigator (Mac OS X style dock)
ssh (full SSH package, including the server)
filezilla (FTP/SFTP/FTPS client)
vlc (media player to replace the included Totem)
sunbird (calendar application from Mozilla)
amarok (popular Linux music player)
songbird (a music player from Mozilla with an interface similar to iTunes)
The names listed for these are their package names so to install any of them it is a matter of typing "sudo aptitude install [package]" at the Terminal. I also updated just like in Ubuntu which I described here.

Linux Mint includes the same firewall I discussed here, but it included a GUI which you can find at System>Administration>Firewall configuration. There are some other differences between Ubuntu and Linux Mint which I also noticed. Ubuntu included a .bashrc file in each user's home directory by default, but Mint does not. Also, for a graphical installer, Ubuntu has one called "Add/Remove Applications" and Mint's is called "mintInstall".

Saturday, April 4, 2009

Configure Cygwin and SSH on Windows

I was a dedicated Windows user for years but the more I get to know the Unix environment the more I like it. Cygwin provides a way to add some of the features of Unix, most specifically the command line, into Windows. Installing Cygwin by itself will give you a Unix shell within Windows, but you can also install a large number of packages along with to gain even more functionality. For my typical Cygwin install, the only extra I like to add is an SSH server.

The first step is to download and run the setup.exe file from the Cygwin website. During installation there are a couple of things to keep in mind. First, the default install location is "C:\cygwin". Like Unix, Cygwin doesn't like spaces in directory names, so the standard "Program Files" isn't a possible install location. The default location really should be fine.

Second, Cygwin gives you the option of going with "Unix/binary" file encodings or "DOS/text". The default and recommanded choice is the "Unix/binary". The only problem with that is that Notepad has trouble reading these types of files. I try to avoid using Notepad whenever possible and the much better Notepad++ will read these files beautifully. Notepad++ became my text editor of choice when I first discovered it a few years ago and I have yet to find anything I like as much for any platform.

The next thing you'll need to attend to is the packages to install. For the base install, you can skip right past this. If you want to install the SSH server, scroll down to the "Net" category. Expand it and scroll down and select "openssh". When you do this "openssl" will get selected automatically. Now finish the installation and you should have a Cygwin shortcut on the desktop.

Launch Cygwin and you will see a Unix shell. To set up the SSH server, there are a few more steps to follow. Enter these commands:
chmod +r /etc/passwd
chmod +r /etc/group
chmod 755 /var
Somewhere is the course of the Cygwin development a bug was created that caused problems with openssh and the default file permissions. These three commands fix that issue. Next enter this command to start the SSH server setup:
Answer "yes" to the next three questions. When you see the prompt: "Enter the value of CYGWIN for the daemon: [ntsec]" you should enter "ntsec". Okay, configuration is done. To start the service, type:
net start sshd
Now you should have a working SSH server on your Windows machine along with a working Unix command line environment. Depending upon what you use for a firewall, you may need to open a port in order to access the SSH server. SSH by default uses TCP port 22.

If you want to install any additional packages, just run through the installer again and select whichever additional packages you want and it will install them for you. For more information on how to use CYGWIN, Lifehacker has a three part tutorial to check out:
Part 1
Part 2
Part 3

Thursday, April 2, 2009

Manage your GRUB boot sequence

If you want to change your GRUB boot settings on your Ubuntu machine, like if you are dual booting Windows and Linux and want Windows to be the default option, there is an easy graphical solution. To install, type:
sudo aptitude install startupmanager
You can find this program by going to System > Administration > Startup Manager. The interface is intuitive with plenty of options and makes editing your boot sequence a snap.

Wednesday, April 1, 2009

How to dual boot Windows and Ubuntu

Having a computer that you can boot natively into multiple different operating systems can be useful. For example, some programs may only run on a certain operating system. If you either do not want to or are unable to virtualize a guest operating system, then dual booting is the next option. While I do use a Windows virtual machine on my Mac for easy access to a Windows environment, I also dual boot with Windows and OS X so that if I need to run a program that is very system intensive, I can do so. Configuring your computer to dual boot Windows and Ubuntu is very easy.

To start, you will want to have Windows installed on your computer. Even if the computer does not have an operating system installed, if you want to dual boot you need to install Windows first. If this is a completely fresh configuration, when you install Windows you can leave blank space on your hard drive for the Linux partition. If you already have Windows installed and do not have any free space for another partition, you will have to make some. Make sure there is some free space on the existing partition before you continue and make sure to do a full disk back up. Messing with your paritions is never something to be undertaken lightly. Even if you are careful and know what you are doing sometimes still go wrong and you could lose everything.

If you are running Windows Vista, you can resize your system partition from within windows. Right click on Computer, then select Manage. Click on Disk Management. Now you can resize the partition so there is space available at the end of the disk, as opposed to at the beginning. If you are running XP, you will need to use the disk partitioner built into Ubuntu. Vista users can use this option too. Insert your Ubuntu installation disk and boot to it. When it loads, choose the first option which should say "Try Ubuntu without any change to your computer". This will start a live session. You will get a completely function Linux desktop without making any changes to your hard drive.

Once you can see the Ubuntu desktop go to System menu, then Administration, choose Partition Editor. Resize the partition so there is space available at the end of the disk, as opposed to at its beginning. For a minimal install, you only need a couple of gigabytes. 8GB is probably the smallest amount of space you'd want to have available. This is enough for a full installation with some space for some files and additional programs, but not a much additional space. Go larger if you like, but I would recommend against going any smaller.

Once you have your disk partitioned the way you want it, start the installer by double clicking the icon on the desktop. The installer is pretty self explanatory until you get to the partitioning section. Choose the Manual option. Ubuntu needs a minimum of two partitions, one for the system and one to use as swap space. How much swap space you need will depend upon how much system memory your computer has and upon how system intensive the applications are that you plan on running. I usually like to go for at least as much swap space as I have system memory. If you need help deciding how much swap space to allocate, you can probably find an article about it on Google.

To create a new partition, click on the free space and click the New Partition button. To make the swap partition, choose Primary, enter the size, choose at the End of the disk, and it should be used as "swap area". To make your system partition, choose Primary, the size listed should be the remaining free space, it should be used as Ext3 journaling file system, and the mount point will be / (forward slash). After that you can proceed through the rest of the installation.

When the installation finishes, you will need to reboot in order to use your new Ubuntu installation. Upon rebooting, you should see the GRUB boot menu. With this menu you can choose whether you want to boot into Windows XP or Ubuntu.

In terms of system interoperability, Ubuntu can read and write to NTFS partitions out of the box. With Windows, you will need to install some software to be able to read and write to your Ext3 partition. You can find it here.