How to record sound directly from output?

You get what we call a line-in input. It is much less sensitive that the mic-in port and every motherboard should have one (the port colour is blue) by default. You can go to sounds options > recording devices to enable this port. Then go to your recording application (like Audacity) and select the line-in for recording.