This very basic information has been posted many times, but is scattered and hard to find. So here it is in a prominent spot.

There are two sections. The first section teaches you how to initially set your grind range and coffee doses. In the US, the prevalence of latte drinking has resulted in many cafes using grind settings that are much too coarse, and doses that are much too high, for straight espresso. The result is that they taste much too bitter and sour. The second section teaches you how to analyze the taste of the shot in a way that allows you to adjust the taste balance to your liking. This is the way the best baristas fine tune their shots. Knowing which taste details go with which shot preparation details is the fastest way to improve your skills.

Initial Calibration of your Grinder You will need a scale that reads to 0.1 grams, fresh coffee, an espresso grinder, an espresso machine with its stock double basket that has no restrictor.

Set your grinder so when pinching the grinds you feel a very fine granularity, just a little coarser than powder.

Load your stock double basket with 12 grams of coffee.

Adjust the grind until you get a shot that weighs 20 to 25 grams in 30 seconds. (when timing the shot count the dwell time, the time between turning on the pump and seeing the first drop, at 50%)

This is you finest grind setting, suitable for light roasts, very acidic coffees, or otherwise very powerful tasting coffees

Repeat the procedure using a dose of 16 grams and a coarser grind. The setting that gets you 20 to 25 grams in 30 seconds as before will be your coarsest grind setting, to be used for very bland tasting coffees

On some machines, this calibration can be off. But it is a good starting point. Don't hesitate to make changes once you have become confident doing the tasting and making the dosing changes described below

Does your shot taste balanced; are the sweetness, acidity, and roasty flavors in proportion?

If the balance of the shot is good, but the flavors are not to your liking, you need to change coffee.

If the flavors are to your liking, but their balance is wrong, with the shot tasting too bland, too in your face, too sour, or too bitter, you can fix it by changing dose and grind.

How to adjust dose and grind to fix the balance for most coffees

If the coffee tastes too bland, the caramels and sugars are masking the flavors. Increase the dose, and coarsen the grind to keep the flow the same. This will reduce the proportion of sugars, while keeping the acid bitter balance the same.

If the coffee tastes aggressive, you need more caramels and sugars, less flavors. Decrease the dose, and make the grind finer to keep the flow the same. This will increase the proportion of sugars, while keeping the acid bitter balance the same.

If the coffee is too bright, with lemon, fruit, apple, wine and other acidic flavors, keep the dose the same, make the grind finer, to lower the flow rate. Make a slower flowing, more ristretto shot. This will reduce the acidity relative to the bitterness.

If the coffee is too bitter, with too much "bright bitter" flavors in lighter roasts, like toast, wood, or lemon peel, or "dark bitter" flavors, in darker roasts, like blackcurrant, clove, tobacco, smoky pine sap, or peat, keep the dose the same and make the grind coarser. Make a faster flowing, more lungo shot. This will increase the acidity relative to the bitterness

Stopping the Shot by Timing, Flow Color or Weight (Added 04/25/2017)

Beginners are advised to time their shots; but this is not best practice.

There are two best practices, pick one depending on your dispostion.

You can stop shots when the flow becomes very pale, translucent, almost transparent. At this point the extraction has ended and any more is just a dilution.

You can stop the shot by brew ratio: Weigh the shot as its being made until it hits the target brew ratio of coffee weight:shot weight. Select the brew ratio according to the roaster's recommendation, or by tasting the level of extraction, i.e. how aggressive or mild the flavors seem. Decrease the brew ratio if underextracted, increase it if overextracted (remember, it's coffee weight/water weight, so more water lowers the brew ratio and raises the extraction, while less water raises the brew ratio and lowers the extraction))

What you will need to do this

You will need a scale that reads to 0.1 grams, and you will need to weigh doses to the nearest 0.1 grams

For many scales, it is easier to remove the basket from the portafilter and weigh it alone.

If you are starting out, it is useful to time shots and weigh them as they are being pulled. A normal double weighs about 35 grams and runs about 27 seconds, and ristretto about 20 grams and runs about 35 seconds, and a lungo about 50 grams and runs about 20 seconds.

Lots of patience when starting out

It helps to understand your grinder. Typically, a 1.5 gram change in dose for doubles will require the same offset to the grind setting to keep the flow the same, regardless of the overall dose being used (the offset is basket dependent). My personal experience is that changes of about 1.5 grams dose creates the tweak from blah to right or from too much to right. I also find that a grind change that would compensate for about a 0.75 gram dose change has the effect of moving the flow from normal to fast, or from normal to slow.

These tricks will not usually work well with Sumatran, aged, or Robusta heavy coffees. They mostly work well with other coffees.

UPDATE: Dan Bollinger has come up very good summary diagram of the dose and grind variations: