The ensign is a maritime flag that is used for the national identification of a ship. The ensign is the largest flag, generally flown at the stern (rear) of the ship while in port. In ports, depending on the ship's origin, it is sometimes identical with a jack on the bow of the ship. Jacks are more common on warships than on merchant ships.
National civil ensign of New Zealand flown from the stern of Hikitia
A maritime flag is a flag designated for use on ships, boats, and other watercraft. Naval flags are considered important at sea and the rules and regulations for the flying of flags are strictly enforced. The flag flown is related to the country of registration: so much so that the word "flag" is often used symbolically as a metonym for "country of registration".
House flags, c. 1900
Burgee of Barrachois Harbour Yacht Club, Nova Scotia, Canada
A courtesy Turkish flag is raised aboard the destroyer USS Truxtun as the ship transits the Bosphorus strait
Superyacht Ariane NI in Toulon harbour, flying her British ensign and a French courtesy flag