How to defend
This is a more general topic and could probably be applied to most games, but I'm going to focus on CS:S. Defending is a surprisingly complicated aspect of CS:S, when to rotate, where to camp, when to pick etc, in this article I am going to cover a few of these points.
Firsts things first, position
Position is probably the most important part of defending. If the enemy doesn't know where you are, they can't aim their grenades or flashes at you, or even just run right past you. However, the important thing about positioning is knowing when to change. For example, If you position yourself to the left of a door one round and manage to kill two or three or more of the enemy, of course they're going to check there the next time they rush. Depending on how well you did you can go back there again, but remember, if they know you're there you'll be an easy target. Also note, if they don't attack your site they won't know you changed positions, so if you sit to the left when they rush, go to the right for three rounds where they don't, don't think to yourself that they won't check there.
Know your position
Again, this is very important, and you'll probably need some help looking around at the different methods of attack and how to defend against them. A lot of camping spots could take a low skilled team out, but if you don't know how the shadows work you could just give your position away; this can be used to your advantage by baiting the other team out, but in all probability you will get killed. As well as shadows, you need to know the different angles for your positions, for example AWPing up from CT spawn to T spawn on dust2 is probably one of the worst positions to be in because of the fact that they can easily take you out before you even see their arm.
When to rotate
This one brings out a lot of teamwork and you'll need your calls to be clear and accurate. Always be prepared to rotate to help your team mates. The key when rotating is deciding when to rotate. With experience you'll become better at figuring out the exact timing (not rotating too late or too early). If your team calls one or two, just prepare yourself for a rotation, but 2 people could easily be used for a decoy. Three or four is a little different, for both only one person of two should rotate, again three or four can be a decoy, but less likely. If four is called the final person can start to rotate but not fully. If all five are called then obviously everyone should rotate. There are a few exceptions to these "guidelines", mainly to do with the bomb. If you spot the bomber, then get prepared to rotate, if you see the bomber rush then everyone should rotate. Finally, if you manage to kill the bomber, then all your team should set a perimeter around it and camp.
Using grenades defensively
Using grenades and flashbangs are a great way to defend, not only can you stop their rush and give time for your team to rotate, but you can also damage or kill them without even seeing them. Use flashbangs sparingly, you usually have two people on a site, so you should really only be using two flashbangs max, and at separate times. Two flashes are all well and good, but it does nothing beneficial if you throw them at the same time. Grenades are a different story, throwing two grenades at once, often referred to as "double nading", can ruin a rushing team. Usually when you rush you are close together and in a tight space, using this to your advantage you could throw both your grenades and even kill all of them with little effort.
As I said just then, use your flashbangs sparingly. Sure, you can stop a rush if you use your flashbangs, but on the whole a few seconds of white screen is hardly going to stop them rushing. When they do rush and are committed into rush, that's when you should flash. You can do it by calling the rush to a team mate and they flash, but you can easily do it yourself. The best way to do it is to just place it on the floor in front of them. As soon as it blows, jump round the corner and spray basically. Or you can aim if you want.
A few final tips
Defending is all about common sense, the other team all using AWPs? Stop complaining and just camp in close-range positions, and vice-versa. Keep comms as quiet as possible, and call as soon as you hear or see anyone. Communication with your team is vital, but too much is too much, keep it strictly on gameplay and any comments can wait until the end of the round. Try not to get yourself killed by pushing or trying to pick as a defender, that's the attacker's job, and there's a reason why they are usually the harder team to play: defending is much easier than attacking. You can have your sights lined up and they all just run into your line of fire.