Article II of the U.S. Constitution makes the President the Commander-in-chief. He can hire and fire generals at his pleasure.
President Truman, as Commander-in-Chief, dismissed WWII hero, in the Pacific Theater of the Philippines, General McCarther in the Korean War(1950-1953). But was he justified?
General McCarther publicly criticized Truman for not expanding the Korean War into China. However, he never actually violated the chain of command and said he wouldn’t privately.