On an old desk (now broken), I remember my dad cut hole in the back of the desk to provide easier cable assess for speakers and power cables. I think it also provided better cooling. (the desk's back was to the wall)
Might want to think twice about it though. If you have a gaming machine it might overheat easy without new air to ventilate it. Htpc not so much.
Otherwise what Jaguarskx said goes. I would think putting it in the pantry would be bad though. jk
Usually you want to keep the temperatures under 60c under load and 30c or so when idle.
Different processors can handle different amounts of heat, for example my i5-2430m likes to run at 90-95c under load (ouch, they automatically shut down at 100c) and 40-70c idle (depends on room temp), while AMD's Phenom II processors aren't built to run over 65ish C.
If the cabinet is completely enclosed then it's a horrible idea to keep it in the cabinet. It's like putting a human in a plastic bag, or a coffin alive. If it has like holes in it somewhere then it's kinda OK, but having it out in the open is optimal.