a) Download the Youtube video
First, you have to download the Youtube video.
b) Extract the audio from the video
You have to install mplayer (on Ubuntu: sudo apt-get install mplayer)
$ mplayer -quiet youtubeVideo.MP4 -ao pcm:fast:file=audio.wav -vc dummy -vo null -channels 2
This will extract the audio from the file youtubeVideo.MP4 and will convert it to a WAV file called audio.wav.
c) Convert the WAV file to an MP3 file
The last step is to convert the WAV file to an MP3 file which is a lot smaller and allows you to save space. For this we are using "lame" (on Ubuntu: sudo apt-get install lame):
$ lame audio.wav audio.mp3
This will take the audio.wav file and save it as audio.mp3. That's it. The file audio.mp3 contains the audio part of the Youtube video.