Unscrew the tension adjustment screw on the gear lever by about four to five turns. This gives you sufficient adjustment travel for the cable tension in both directions. Thread the cable through the lever.
Now shift through gear by gear. Starting from the seventh sprocket, if the chain is unwilling to climb onto the large sprockets, the tension must be increased and reduced towards the small sprockets.
Pull the new cable tight and screw it to the rear derailleur. The cable housings must be fully inserted into the frame stops. The chain is on the smallest sprocket when the rear derailleur is relaxed.
Important for precise shifting: The shift cable must be in the correct position in relation to the clamping screw. Look for a groove or clamping marks on the old cable. This is not always as easily recognisable as here.
You will always find cable adjusters on the gear lever, and often also on the rear derailleur. These push the cable housing away from the rear derailleur and thus tension the shift cable. Only turn in 1/4 turns.