Authority as Commander-in-Chief on the battlefield
As Commander-in-Chief, the U.S. President outranks any military officer and so has the inherent right to assume command on the battlefield. However, because presidents are rarely present in war zones, and often have less military experience than the military commanders, only two presidents, George Washington and James Madison, have so far done so. Washington personally led a federalised militia force of approximately 15,000 troops to quell the Whiskey Rebellion during his second term, although he was not present during any of the skirmishing in the relatively bloodless conflict.
During the War of 1812, President Madison was under enemy fire on August 24, 1814, when American forces were routed by British troops in Bladensburg, Maryland. Madison, incensed by the American commanding general's incompetence, was on the scene and personally assumed command of the only remaining American force, a naval battery commanded by Commodore Joshua Barney. He did so to stall the British invasion of the American capital, but his efforts were unsuccessful, and the British burned Washington over the next two days.
During the American Civil War, President Abraham Lincoln considered personally assuming battlefield command of the Union Army, and studied military texts when he became frustrated by the incompetence and lethargy of his generals. He actually came under enemy fire in 1864 during the Confederate attack on Fort Stevens in the District of Columbia, but did not exercise battlefield authority as commander-in-chief at any time.