Here is how to deal with a bad roommate. I have had plenty of them. I have learned that a roommate can get on your nerves without even knowing they are bothering you.
You might be furious with them for something they do, but they have no idea. You need to communicate. Tell your roommate that ____ is bothering me.
Sometimes it is a good idea to outline a few things before you move in with someone. Tell them what you don't like and what you will not tolerate. For example, if you do not tell them that you hate them walking into your room without knocking, they might do it and make you mad. At least if you tell them, they have no excuse.
If your roommate is just annoying or mean on purpose, try to move out. If you are under lease, advertise that there is a room for rent and get someone to take up your lease so you can leave. The best thing to do is to get out of the situation. If you are in a dorm, think about moving to a private dorm. If you move mid semester most of the time you will get a huge discount. Just tell housing the problem you are having.