Will any Shimano mountain bike shift cable set work with any Shimano mountain bike derailleurs and shifters? (Forgive me if this question has been asked before - but I don't know if I'm searching with the correct keywords to find the answer...)

My rear derailleur cable is stuck hard into the side of its tube, meaning I can't shift gears. I want to replace it, but I'm a novice and I'm not sure exactly what replacement cable I need. The bike is a Cube Analog 2014, with Shimano Altus SL-M370 Rapidfire Plus shifters and Shimano Deore RD-M592 SGS Shadow 9-speed rear derailleur. I found this Shimano shift cable set, but it seems like this is a generic kit. Would this work? Would I need to cut it to the right size for my bike, or are they always the same size?
Yes it will. The important factor for compatibility is the head of the cable that sits inside which will be the same. The cables will be significantly longer than you will need, so you'll have to cut them down to size. Use the old cable housing to determine the length of housing that you need (provided that it's been working well at the current length). Then thread the inner cable through to the derailleur and adjust your cable tension, then cut off the excess cable.