It wasn't easy though. City were cruising after an hour. Ben Nugent had headed CIty into a half time lead, soon after the break Aron Gunnarsson had headed in City's second (celebrated in the pic).
That makes it three goals in a row where a Peter Whittingham corner has been converted with a goalscoring header after Matt Connolly got the winner against Middlesbrough last week.
The final 30 mins saw Barnsley force themselves onto the Bluebirds and Marshall needed to be sharp to keep a number of efforts out.
Cardiff's chances were restricted to breakaways one of which saw sub Gestede's shot saved and Kimbo's follow up sent wide.
Barnsley pulled a goal back and made it very uncomfortable for City as the hosts poured forward. All their pressure came in the 90 mins. Once the board had gone up for four mins added time City regained control and managed to waste enough time to see the game out.
Simon Lappin, on his debut, was sent off for a 2nd yellow. His decision to foul the Barnsley player stopped an overlap and could be seen as taking one for the team.
With Palace, Middlesbrough and Hull all losing it was a very satisfactory trip to Yorkshire for the Bluebirds.
Mind you it was a bit chilly in the away end but the final whistle was very warming and very welcoming.
The win was the first this season for the team in their Blue away kit.
Next up it's Derby away on Tuesday.