Every pirate ship was different, me hearty. But they all needed a crew, and each crew was a different size and made up of different people, but, begad, the ships were nearly always over-crowded and carrying the people below.
A pirate ship’s captain was usually picked and voted in by the crew. It’s also how most of them got replaced - the crew simply decided they didn’t want them to be captain any more and picked somebody else for the job.
Sailors who were authoritative and daring always stood a better chance of getting picked.
Not that being in charge came with many rights - during a fight they could boss the crew around, they could also hit, stab or shoot anyone who disobeyed them. Plus they also got more of the treasure they stole from any of the ships they captured, but that was about it.
When their ship wasn’t fighting or chasing another boat, the crew could take the captain’s drink and food, or swear at him, and not be in lots of trouble for it.
The quartermaster was second-in-command on a pirate ship, and was picked by the crew (just like the captain).
He ran the ship when they weren’t in action, made sure the captain treated the crew well, and divided up the food, treasure and sorted out fights. He also, like the captain, received a larger percentage of any treasure captured, plus on the occasion that another boat was captured he would often receive it so that he could go off and be a captain of his own ship.