The first step to repair cracks in walls is assessing whether you have plaster or drywall, also called sheetrock, plasterboard, or wallboard. Only older homes were finished with plaster, a goopy substance that was carefully spread onto slatted boards called lathe. Plaster generally cracks and crumbles if you try to hammer a nail into it, while drywall is made of small aggregate material and plaster sandwiched between two pieces of paper. Drywall won't crack with nails or screws.
Repairing plaster and drywall cracks are similar processes. With plaster, changes in moisture can cause a lathe board to pull out from studs when nails lose their grip. If it seems like a warped wall accompanies the crack, first you need to reattach the lathe by nailing more nails through both the plaster and lathe. Then, hairline cracks can be filled. A plaster paste will either come in a powder or premixed from your home improvement store. Using a putty knife, fill the cracks with a small amount of paste. After it dries, you can sand it and paint the area.
Drywall repair more or less follows the same steps. The patch compound will be a different material though, sometimes called joint compound or spackling putty. Drywall will also withstand more sanding, so don't hesitate to spackle in two steps. The first stage will roughly fill the hole, but the second application will make the surface identical to the rest of the wall. In-between, sand with a very fine grit rated for use with drywall. If you wrap the sandpaper around a piece of scrap wood, you'll make a flat surface and avoid forming trenches or dips on the wall.
Sometimes larger cracks both in plaster and drywall need to be cleared of debris. With a utility knife, cut out a trench slightly larger than the crack and then brush it with a paintbrush to get out dust and dirt. The patch putty will have more surface area to bond to when the crack is large enough. Apply the paste as before, following it with paint.
To repair cracks in walls that are very wide, you will need a little more structure to make the repair stick properly. This is where patching tape, also called mesh tape or joint tape, comes in handy. Cut enough to cover the crack and extend a few inches in each direction. Now use more putty and a wider putty knife to push the paste deep into the crack using diagonal strokes that cross perpendicular to the crack