Many people don't know how to deal with grief - I've had friends tell me as much. So they either talk too much and end up saying something inappropriate, or they keep their distance.
The following six words may not sound like much, but they, or variations of them, are all you really need to tell the grieving.
"I'm so sorry for your loss."
It helps if the words are accompanied by a hug, but that's not mandatory.