Listening to grieving people is the most important thing you can do. Listen in a non-judging way, and allow them to tell the story or stories over and over if they need to. Repetition is often a key part of the healing process.
Share your memories of the loved one, too. Reflect on the feelings they are experiencing--but as you share, be careful not to start one-upping their feelings, or comparing your loss to theirs. And don't say "I know exactly how you feel." It's usually much more helpful to say something along the lines of "I can't imagine what you must be feeling right now," because most grieving people feel like no one else could know what they're experiencing.
It's also important not to tell people that time heals all wounds, or that their loved one is in a better place. While that may be true (depending on your belief system--and theirs) they're not in a place to hear that at this point.
Each person recovers from grief at his or her own pace. Some can recover quickly, while others can take a full year or more (this will also depend on the severity of the loss). Be careful not to impose a time limit or tell people to get over it and move on--feeling that they've grieved too long can cause people to suppress their feelings, and slow or stop the healing process.
Understand that grieving people are very likely to have emotional setbacks, even after a long period of healing and outward "improvement." Something could spark a memory that causes them to spiral downwards--dates that were important in the loved one's life, such as birthdays, anniversaries, and holidays, are often triggers for setbacks.
Be there for the grieving person as long as (s)he needs you.
Remember that there's no definitive way to experience grieving, and that everyone experiences a unique set of feelings or physical symptoms. Understand that the grieving person will always feel the loss, but that he or she will learn to live with it over time.
It may sound strange to talk about celebrating, but it can help grieving people heal. Help them celebrate the life of the loved one they've lost. Help them develop rituals they need to get through the difficult early stages of the grieving process.
Sometimes grieving people can go to extremes--if you notice signs of suicidal behavior or fear they may harm themselves or others, it's your moral, legal, and ethical duty to refer them to a mental health professional.