Pretty simple.
As Commander-in-Chief, the U.S. president can relieve any officer of their command or position, but removing them from the armed forces is a separate and more complicated matter.
Relieving a commander: The president can remove an officer from a specific position, such as President Harry Truman's firing of General Douglas MacArthur during the Korean War. In 2025, President Donald Trump fired Chairman of the Joint Chiefs of Staff Gen. C.Q. Brown and other high-ranking leaders, citing his authority to choose his military advisors.
Forced retirement or rank reduction: For three- and four-star generals and admirals, their senior rank is tied to a specific command position. If the president removes them from that post, the officer typically reverts to a lower, permanent grade. This financial incentive usually prompts them to retire, though they may not be officially "fired" from the military.
Firing from service: Under U.S. Code Title 10, an officer can only be fully dismissed from the armed forces under specific circumstances during peacetime, such as by a court-martial conviction.