This should work on any recent Linux machine using PulseAudio as its primary sound system.
In the telecom world looping back microphone input to a speaker’s headphone is the norm. This allows people to hear their own voices so that they can appropriately modulate their speech.
Many computer systems don’t implement loopback by default. Some make it particularly difficult to implement. For recent distributions of Linux shipping with PulseAudio (for example, Fedora 19) as the default sound system the fix is easy.
The command to turn on loopback for a given user is:
pactl load-module module-loopback latency_msec=1 channels=2
I don’t recommend automating the switching on of this “feature” as you probably won’t want it active most of the time.
Disabling the module can be accomplished with this command:
pactl unload-module module-loopback
As on Windows, I noticed a bothersome degree of latency as well as overmodulation and ambient noise (crackling, distortion) in the loopback audio. No doubt I’ll have the solution to these problems once I’ve spent several more hours scouring the Internet and experimenting.
Man, I hate Linux sound.