replacing shifter cable housing? My rear cable housing got torn apart while I was tunning gears as you can see in the picture. I'm quite new to cycling so i'm not sure if i should replace the whole cable or just the part of the housing which got damaged?

Also if I'm just replacing the cable housing, do i have to cut the cable as there is a nut at the end of the cable which stops me sliding the housing out of the cable?

(just for your information i have shifting issues in the rear derailer as well: i.e., for certain gear combinations it sometimes overdo the gears when upshifting and downshifting. Maybe be this is related to a bad cable as well)
Its likely that your bad shifting is due to messed up cables or a misadjusted derailleur. 

You can either cut the cable crimp off at the end of the cable with a pair of pliers, or pull it off with a pair of pliers. 

As for replacing the cable housing, you can either get your bike shop to cut a piece of housing of the right length by taking your old housing to them, and cleaning up the cut with a file + awl so its flat and the hole is completely open, or you can buy housing kits from companies like Jagwire and cut it yourself (but you will need a bicycle specific cable+housing cutter like Park Tool CN-10 or a dremel to cut the housing properly). There is a nice tutorial on how to replace your housing here. Another good page on prepping housing is here. 

As for replacing just the housing vs replacing the housing + the cable, its generally a good idea to just replace the housing + the cable, just because its not all that much more expensive and if your cable has some rust on it or has been damaged, it may lead to poor shifting even with new housing. I always replace the cable and housing together, just to avoid problems. 

EDIT: I zoomed in on the picture. The cable is toast. Get a new cable.