Answer
The answer to the question is six years, encompassing two terms: Hassan Sheikh Mohamud served as the President of Somalia from September 2012 to February 2017. He was elected in a historic election that marked the end of a transitional period and the restoration of a permanent government in the country after more than two decades of civil war and instability.