As a general rule, most sailing ships had very similar command structures, usually based on the same command structure as a naval vessel. There were of course some variations on these, as each nation's navy did things a bit differently. I'm sure I haven't quite covered everything, but here is a list of typical command structure and other jobs aboard a sailing vessel.
CAPTAIN
The captain is responsible for everyone and everything that occurs on his ship. He is commissioned by the government of the navy he serves, or appointed by the ship's owner's if it's merchant vessel. There is a difference between the Captain of a ship and a captain's rank in the navy. There is only one Captain on board a ship, and that person's power is absolute, to the point of life or death. Naval ships also used Lieutenants. One or more Lieutenants assist the captain in the command position. Often taking deck watches, these officers are completing their command training under the eye of the Captain.
Things were a bit different on a pirate ship, pirates adopted command structures they were most familiar with. As most had served in one navy or another, they usually adopted a naval command structure to keep order aboard ship. The captain was elected by the crew, usually when the ships articles were drawn up. The Captain of a pirate ship was usually only in charge during battle, the rest of the time the Quartermaster was generally in charge. The captain of a pirate ship did not have absolute power.
MASTER OR NAVIGATOR
The captain is usually the ship's master on a merchant vessel, in the absence of a commissioned officer. The Master usually holds rank over every officer except the captain and his lieutenants. His primary duties are to navigate the ship, and are usually considered the most important person on a ship besides the captain. The master usually had a map book, with all of the maps that he's collected from various places at sea. This book is often the most valuable object on board the ship, as without it, navigation becomes impossible. Therefore, it is protected at all costs. Officers who report to the Master include the Master's Mate, Quartermaster, Helmsman, and the Purser.
FIRST MATE or MASTER'S MATE
This is usually a sailor training to become a master.
Skills are per Master.
QUARTERMASTER
This sailor is specifically charged with organizing how the ship is steered. On some ships, the Master Gunner reports to the Quartermaster instead of the captain. In many cases, the Quartermaster and the Master are the same person, and may also fill in at the Purser; generally because they need to know how to read and do mathematics. On a pirate ship, the Quartermaster usually had more power than the captain, the Quartermaster was usually elected by the crew immediately after choosing a Captain, and it was his duty to represent their interests. The Quartermaster was usually also in charge of discipline aboard a pirate ship, unless the crime committed was a major offense, then the crew would hold a trail on-board to determine punishment.
BOSUN
The Bosun (sometimes called the Boatswain) is in charge of the working and sailing of the ship, including deciding upon the discipline issues of the ship. This is usually an enlisted position, not an officer. Selected from the most capable and loyal sailors, Bosun's could be brutal when carrying out the Captain's orders. Because things could sometimes get pretty noisy aboard ship, especially during storms or during battle, the Bosun would usually give his orders with a piercing whistle that could be heard even through the chaos of the fiercest battle.
The following people report to the Bosun: Bosun's Mate, Sailmaker, Captain of the Tops, Master of the Forecastle, Master at Arms, Weaponsmith, and the Carpenter.
MASTER GUNNER
If the ship is armed, this artillery officer handles the heavy weapons aboard. He is in charge of training the crews to man these weapons. He is also in charge of purchasing ammunition. On some ships, the Master Gunner reports to the Quartermaster rather than the Captain. This position is often filled by Lieutenants, Ensigns, or Midshipmen.
The only positions aboard ship who report to the Master Gunner are the Gunner's Mate and Gun Crew.
SURGEON
Though not a line officer, the surgeon still reports to the captain. The surgeon is in charge of the health of the crew. Normally this person is given high rank in deference to his or her skill and medical training, and is not part of the command structure of the ship. On some vessels, the Surgeon also served as the Carpenter, or visa versa.
The following people report to the Surgeon: the Surgeon's Mate and the Loblolly Boy.
HELMSMAN
Each watch must have a trained man at the helm (and he must answer to the Master). This means that there are usually many helmsmen aboard any given ship. A helmsman and a pilot are different; the pilot is usually an expert on a particular harbor.
PURSER
The purser is the provisions officer and is in charge of food, clothing, and cargo for the ship. The following people report to the Purser: the Steward and the Cook. On some ships, this job was also filled by the Quartermaster.
BOSUN'S MATE
These sailors pass orders through the ship, after blowing their whistles to get everyone's attention. They also directly administer any discipline decided upon by the Bosun or the Captain.
SAILMAKER
This sailor is in charge of making repairs to any damaged sails as well as tending to the general maintenance of the sails.
CAPTAIN OF THE TOPS
This sailor is in charge of the rigging and all of the topsmen (men in the rigging). He is usually one of the most senior mariners on the ship. This is also one of the most dangerous places to be on board a ship, especially at night.
MASTER OF THE FORECASTLE
This sailor is in charge of mooring, anchoring, sounding, the foremast jacks, and the capstan.
MASTER AT ARMS
This sailor must keep track of who is given small arms aboard a ship. He has the key to the small arms locker.
WEAPONSMITH
This sailor is in charge of maintenance on the small arms of the ship.
WEAPON'S MATE
This sailor is in charge of training crewmen to use their personal arms in all boarding actions, for defense or capture of another ship and her crew.
CARPENTER
The Carpenter is responsible for taking care of the ship's construction (the hull, etc). The Carpenter usually has a Carpenter's Mate and crew of workers that work directly with him (called the Carpenter's Crew). Pirates may not have a Carpenter to do repairs, which is why many of them steal ships.
TOPSMAN
A crewman that works in the tops of the ship, among the rigging. They handle the sails, ropes, climbing the masts, and posting a watch in the crow's nest. They are usually among the most experienced sailors on a ship.
CAULKER
The caulker is responsible for caulking and sealing joints in the ship. The main materials used for caulking are fibers and tar.
SWIMMER
The swimmer is responsible for repairs done to the underside of the ship while it is underway. This may be the same person as the Caulker.
GUNNER'S MATE
The Gunner's Mate assists the Master Gunner in all things concerning the heavy weapons.
GUN CREW
The Artillerist's Crew fire the heavy weapons under direction from the Artillerist and Artillerist's Mate.
SURGEON'S MATE
This sailor acts as an assistant to the surgeon in whatever tasks the surgeon needs.
LOBLOLLY BOY
This sailor acts as a male nurse for the surgeon
STEWARD
The steward acts as an assistant to the purser (performing whatever duties the purser deems appropriate).
COOK
The cook is responsible for actually preparing the meals for the crew. They are also responsible for taking back any naval vessels taken over by terrorists.
CARPENTER'S MATE
The Carpenter's Mate(s) assists the Carpenter in all repairs. They also help coordinate the Carpenter's crew.
COOPER
The cooper is in charge of repairing barrels and ensuring that all barrels and crates are properly maintained.
CARGOMASTER
The cargomaster is in charge of storing the cargo so that the ship rides evenly and there is minimal damage in shipping. They are in charge of loading, unloading and storing cargo. The Purser counts the cargo in and out, the Cargomaster stores it. Commonly either part of the purser's staff or part of the bosun's staff. Usually not a separate person, but implemented as extra duty on one of the other mid-level officers.
Work inspected by Lieutenant and (if he feels like it) ship's master or Captain.
CARPENTER'S CREW
The Carpenter's Crew are assigned to help with the maintenance and repair of the ship.
DECKHAND
A crewman assigned to the deck. Handles the ropes, helps with the anchor, helps with docking, takes depth soundings, other duties as assigned.
MESS MATE
A crewman assigned to the cook. Helps prepare the meals, fetches food from the stores, sets and cleans up the dinnerware, and other tasks as assigned. Often, a landsman will start in this position.
FIDDLER
The fiddler plays for the crew while they worked or during times when they were not on duty. They help maintain morale on the ship and provide entertainment during the voyage. Not all ships are fortunate enough to have a good fiddler on board.
CABIN BOY
The captain and occasionally some officers may have a young man (someone not yet an adult) that acts as their servant.
RATCATCHER
The ratcatcher is responsible for ridding the ship of vermin, mostly rats. They need to protect the ship's stores and cargo from being destroyed by vermin.