Cmmon courtesy is a must at the gym, as it is almost anywhere else. Here are some pointers:
Work-in
Share equipment you are using with others while you are resting in between sets.
The only time you should retain possession of weight equipment while you rest is when you're using a bar stacked with weight plates. It tends to create a lot of hassle for two people to work in with each other since between each set you'd need to slide in and out multiple weight plates from the bar.
Courtesy
If someone is using a machine that you're waiting for. Before jumping on while they are resting, be polite and ask them "Are you finished?" or, "How many sets do you have left?".
If someone is in the middle of a set and you want to use the equipment next, don't break their concentration by asking to work in or by standing nearby looking impatient or worse by staring at them. Wait inconspicuously until that person completes the set.
Resetting machines
If you work in on a machine with other person, after you've done your set make sure you reset it to where the other person had it.
Do not personalise equipment
If you've either raised the seat or adjusted the handles to accommodate your small or large proportions, ensure that to return the equipment to its original settings once you're done.
Also read: Five super body-building foods