In military fiction they some times show Destroyer's, Frigates or Submarines being commanded by Lieutenant Commander's or Commander's (and even in one book I read a RN Sub was commanded by a Lieutenant, but this was a WW2 novel). My question is this, what is the minimal rank an officer must be in order to be eligible to command his or her own vessel? (I mean actual command, not taking over in an emergency or being in charge of one of the duty shifts). I would love an answer for both the Royal Navy (UK) and the US Navy. Thank you.