The tourists justified their decision to bowl first on a rock-hard pitch at the Sher-e-Bangla stadium by grabbing four wickets with just 59 runs on the board.
Shakib and Rahim joined hands at that stage to stitch together a fifth-wicket stand of 86, before the hosts suffered two quick blows to slip to 150-6 midway through the afternoon session.
Shakib fell leg-before to veteran left-arm spinner Rangana Herath for 55, before seamer Shaminda Eranga had new batsman Nasir Hossain caught behind in the next over to claim his third wicket in the innings.
Debutant opening batsman Shamsur Rahman smashed 33 of the first 59 runs with the help of seven boundaries, but failed to build on the fluent start in the morning session.
More From This Section
Bangladesh lost three wickets in successive overs to slide from 35-0 to 40-3 as Eranga removed Tamim Iqbal and Rahman, and captain Angelo Mathews trapped Marshall Ayub leg-before.
Suranga Lakmal dismissed Mominul Haque before Shakib and Rahim batted out till lunch.
Bangladesh left out Imrul Kayes, Mohammad Mahmudullah and Abdur Razzak from their initial squad, and went in with three quick bowlers in Rubel Hossain, Robiul Islam and Al-Amin Hossain.
The tourists omitted unorthodox spinner Ajantha Mendis and preferred all-rounder Dilruwan Perera in the first of two Test matches.
Sri Lanka will also play three one-day internationals and two Twenty20 games during the tour that ends on February 22.