South Africa successfully reviewed the openers’ wickets in their favour after Fernando and Dinesh Chandimal, out lbw for nine off left-arm orthodox Linde, were given not out by the on-field umpires.
Spinners kept striking as Aiden Markram sent back Dhananjaya de Silva for 31 and Maharaj got two including skipper Dasun Shanaka and Wanindu Hasaranga as Sri Lanka slipped to 121-6.
Asalanka survived a reprieve on 36 when he was caught at mid-wicket off Linde but the delivery was adjudged a no ball with more fielders outside the inner circle than allowed.
Shamsi, a left-arm wrist spinner, finally got Asalanka caught behind to deny the left-hand batsman a half-century.
Dushmantha Chameera hit a useful 29 to help Sri Lanka go past 200 runs and bat out their 50 overs after they were 166-8 in the 42nd over.