We live in a world where there are plenty of very good people dotted with a number of rude people that project their perceptions on others. They unfortunately have no problem with violating a sense of peace that is needed in society for social cohesion. You can use three strategies that can be used at work or in your personal life. They include engage, reject or confront.
First understand that while rude behavior has been sensationalized in popular media as a sign of confidence it is actually a character flaw. It is the exact opposite of what it portrays. People who are rude are either deeply wounded or lack the ability to accept social rules and therefore are unable to fully comprehend their behavior.
Engage: Engage with the person by saying "hi" or "how can I help you?" which often puts them on notice that you understand their behavior. It also shows that you do not shy from conflict and is often the best way to diffuse bad behavior.
Reject: Of course there are some people that don't respond well at all to engagement, friendliness, or anything else. They are jerks and should be avoided. This means don't acknowledge their comments, don't communicate with them, and generally give him/her the cold shoulder.
Confront: There are some people who are persistent in their rudeness and this may occur if you share social networks. If you can't engage, or avoid, and they continue to be rude then feel free to confront and let them know this behavior will not be tolderated.