The hosts slumped after winning the toss and choosing to bat.
Fast bowler Shoaib, who played his last test against India in Karachi in February, took two for 17 from six overs. Shoaib was banned from cricket for two years in November after testing positive for banned substances but was later acquitted.
Shoaib first struck in the fifth over when AB de Villiers played a ragged shot to a wide delivery and was caught behind by wicketkeeper Kamran Akmal for two.
Four overs later Hashim Amla, who scored five, attempted to leave a legside delivery from Shoaib and gloved a catch to Akmal.
Graeme Smith stood firm for 44 balls for his innings of 28, which ended when he edged leg spinner Danish Kaneria onto Akmal's gloves only for Younis Khan to take the catch at slip.
Ashwell Prince then played a wild cut to a delivery from fast bowler Mohammad Sami and was dropped by Akmal.
But four balls later Prince, who scored two, repeated the stroke and this time Akmal took the catch.
Herschelle Gibbs, playing pending his appeal against a two-test ban, was dropped by Younis and Akmal but with his next ball Kaneria trapped the South African in front for two.
Jacques Kallis, who was 15 not out, and Mark Boucher, who was on three, nursed South Africa to lunch without further drama.
Shoaib was one of three new faces in a Pakistan team that also included batsman Mohammad Yousuf and Sami.
The casualties from the team that lost the first test by seven wickets in Centurion were batsman Faisal Iqbal and fast bowlers Naved-ul-Hasan and Shahid Nazir.
South Africa named an unchanged side.
Reuters PM RN1659