Replacing door locks is a last resort. You have gotten this far, one of two things has happened. The lock is a goner and needs to be replaced. The other is, you decided that it looks terrible and a new one would look a lot nicer. Either way, you have to replace it.
For related information see the articles 'Troubleshooting Door Locks' and 'Troubleshooting Door Problems'.
Three things matter with a door lock. The size of the main bore, the size of the strike bore and the back set from the edge of the door. The back set is less of a problem than it used to be. Most new locks have adjustable back sets The two normal ones are 2 3/8" and 2 3/4". Most new locks support both dimensions. Does that 3/8" really matter? Well, yes. A 2 3/4" back set lock will not work in a door bored for 2 3/8".
Purchasing Door Locks
You will want to take the old lock out before you purchase the new one. Although locks have gotten more standardized over the years, there are still variations. Write down a few key dimensions before you go shopping.
Door locks start out a around ten dollars and can go up to over a hundred dollars. Like anything else, quality and appearance are big factors. Obtain a lock that will fit your door. Follow the instructions for installing it. Most of them work similarly. The strike cylinder goes in first and then the two halves of the door knob screw together with the key side facing out. One caution, lever locks are handed and not all of them can be reversed. Make sure you check this out if you obtain a lock with a lever handle.
Removing the Old Door Lock
Most of the time the only you tool you need is a phillips screw driver. Many, (but not all) residential door locks are held in place by two long machine screws. These are located on either side of the door knob on the inside of the room. When you unscrew them, the two halves of the door knob assembly should come apart.
The screws are fairly long, so if you use a hand screwdriver, it will take a little bit of time. It is best to alternate between the two screws so that you can pull the handle out part way. Otherwise the angle for the screwdriver may give you trouble.
Retaining Buttons
Some door knobs have a retaining clip that hold the knob on. Again this clip will be on inside of the room. It may be a long flat button or it may be a button inside of a small hole. You will need a small nail if it inside of a hole. You push in on the button and the door knob will release, allowing the cover plate to come off.
Inside of the cover plate you will find two screws that hold the main assembly together. Remove the screws and the two halves of the door knob will come apart.
Once the lock is taken apart, you can remove the strike assembly. This is held in place by two screws on the edge of the door. The strike plate is also held in place by two screws. If you are replacing the door knob you will need to remove all of these items.
Installing a New Door Lock
Once you have removed the old door lock, installing the new one is pretty simple. Again, assuming you have a lock that fits your door, you should only need a screw driver.
Installing the Strike Assembly
Most locksets have an adjustable backset, so they will fit a door that is either 2 3/8" or 2 3/4" to the center of the main bore. You may need to set the strike assembly to the correct backset before you install it. Take a quick look at the instructions. Once the backset is adjusted, intall the assembly with the two screws provided. Install the strike plate in the same mortise that it was in originally. If you have to trim it, use a sharp chisel, removing only enough wood for the plate to seat flush with the door jamb.
Installing the Lock
Put the half of the lock with the female cylinders that recieve the screws in first. Align the other half of the lock up with the screws and push the halves together. Make sure you start the machine screws with your fingers, getting them started by a couple of threads before you use the screw driver or power drill. Once the screws are tightened the lock is installed.
Test the function of the lock, make sure it closes, latches and opens correctly. Try locking the door and opening it with the key.