Xavi Hernandez, Catalan coach decided to give returnee veteran defender Dani Alves his second Barcelona match placit him in the right wing-back position in a 3-5-2 formation, while the likes of Ronald Araujo, Sergio Busquets and Jordi Alba were all named in the starting line-up.
Linares, who play in Group II of the Primera RFEF, were the side who started the game the quicker, but Barcelona had the first clear chance to score through Araujo. Alves' pinpoint corner from the left was met by the Uruguayan, who rose highest but saw his header towards the far post go just wide.
Barcelona youngster Ilias Akhomach had a good chance to give his team the lead in the 18th minute, but under pressure, he dragged his effort off target. Then, a minute later, Linares took a surprise lead through Hugo Diaz. Fran Carnicer sent in a cross from the right and Diaz got away from Oscar Mingueza to get his head on the end of it and guided his effort past Neto.
Xavi made the needed changes after the halftime interval as Barcelona brought in Dembele, Gerard Pique, Frenkie de Jong.
The addition of Dembele, in particular, saw the Linares defenders begin to panic, and it took 18 minutes before the Frenchman got Barcelona back in the game.
After receiving a pass from Mingueza, Dembele shifted the ball away from Alvaro Barbosa and sent a left-footed shot towards goal that went into the bottom left corner, although perhaps Linares 'keeper Brimah Razak should have done a bit better.
It then felt inevitable that Barcelona would go on and grab a winner, and so they did. Linares had the ball in the back of Barcelona's net in the 67th minute, but Hugo Diaz was adjudged to have interfered from an offside position, and one minute later the Catalans were ahead.
Ferran Jutgla received the ball on the left wing and came inside before turning Linares centre-back Lolo Guerrero inside out and firing into the far corner of Razak's goal to give Barcelona the lead. With Dembele on the pitch, Jutgla became more involved for Barcelona.
The drama was not over there, though, as the ball hit the woodwork on two occasions in the final 15 minutes - first Cristian Carracedo for Linares and then Dembele for Barcelona.
Barcelona were made to suffer the right to the very end by Linares, but Dembele and Jutgla's goals mean that they are into the last 16 of the Copa del Rey.