If a child is loved he knows there is unconditional love at home and no matter how he behaves he is loved. That's not the case at school - he has to behave a certain way to be "loved" at school. School also has a consistent structure - and let's face it, most of us are not all that consistent with how we teach our kids.
If he comes homes, decrompresses after the school day and then gets your attention when he misbhave he gets rewarded for negative behavior. We scold our kids, spend time talking to them ,etc when they misbehave. So here's my suggestions -
1 - tell him ahead of time (the night before, then again in the morning, then again when he gets home) what your expectations are for after school and time at home. Tell him in positive ways, tell him you look forward to his good behavior, that you know he will act in good ways, and give examples of what you expect and the behavior that you don't want to see. Encourage him, tell him you are so proud of him when he behaves well at home as well as at school.
2 - When he gets home give him time to de-compress. Men need their cave time and he's a little man. See if he wants to chill in his room or relax on the living room floor, etc. Give him that time if he wants it.
3 - give positive feedback on good behavior - tousle his hair, kiss on the head, tell him how proud you are of that good thing he just did or the calm way he handled something. TEll him in terms of "I love it when you handle a difficult situation so well - I'm so proud that you're growing up into such a nice young man".
4 - Treat bad behavior very matter-of-factly, no yelling or stern-ness in yoru voice, no long talks or asking him why he does soemthing. So if he has a tantrum, pick him up, alsmot ignoring the behvior, bring him into his room and simply state "when you're ready to stop screaming (crying, whining, etc.) I'd love for you to come out and be with us.
5 - Commiserate with him - in advance - like the night before at bed time. Acknowledge that it's tough to be on best behavior all day at school and you understand that when you come home you just want to break out and let loose. But that we all can't do that becuase then everyone in the world would be fighting at the end of the day. ASk him what he thinks will help him relax after he gets home from school - then go to suggestion 1)
Realize that he's only been on the planet for 5 short years and he's still learning his social skills. He's got social training wheels on and he's trying to balance, steer and brake. It's tough to be in a classroom all day making his teacher & fellow students happy - and he knows you love him no matter what so he dumps out a day full of holding it all in! It's good that he knows he's loved at home!
He'll grow up fast and you'll wonder where these days went. I miss my boy being 5 - even though he made me crazy all those times. ;o)