The duties of the rank would depend on the position he held aboard ship. The above-noted officers provide a bit of a cross-section.
Lt. Cmdr. Upshur was senior officer of the USS Frolic, and therefore its commanding officer and "captain." Although not a captain by rank, ship commanders were traditionally addressed as "captain.")
Lt. Cmdr. Allen was second-in-command of the Ticonderoga; older tradition would have referred to him as "first luff" or "first lieutenant," back in the pre-Civil War days when there was no rank of Commander or Lt. Commander. The new term of "executive officer" was evolved for the position instead, although I'm not clear on exactly when that term came into common use.
Commanders Stembel and Harrell were commanding officers of the Canandaigua and Kearsarge, respectively.
Commander Wyman was commander of the Colorado, but since that was the squadron flagship, he would frequently have had Rear Admiral Goldsborough aboard also, along with his staff.
(A bit of elaboration: once upon a time, there were just three officer ranks in the US Navy: Captain, Lieutenant, and Midshipman-- basically an apprentice Lieutenant. Promotion was by strict seniority but the number of Captains and Lieutenants was fixed by law, so it tended to take longer and longer for promotions to happen; it was not uncommon to find Lieutenants that had been at that same rank for decades through no fault of their own, and Captains who were far too old and infirm to go to sea. "Passed Midshipman," originally an indicator that the midshipman had passed his examinations and was eligible to be commissioned a Lieutenant, became a rank all its own; and lieutenants commanding ships began to be referred to as "Lieutenant Commanding." The rank of Master evolved from the position of Sailing Master, originally an enlisted or warrant grade, and came to be understood to be between Lieutenant and (Passed) Midshipman (because it was common for a senior midshipman to take on the duties of sailing master). That was the state of affairs at the beginning of the Civil War. Midwar reforms created the rank of Ensign to replace Passed Midshipman, Masters evolved into the modern Lieutenant (junior grade), the new ranks of Lt. Commander and Commander were officially established, and the ranks above Captain (Commodore, Rear Admiral, Vice Admiral, Admiral) were created.)