But only if you have right tools installed in your distro. Often, some most popular Linux distribution like Redhat / Fedora do not come bundled with mp3 support. Here is quick take for you to how to do this.
Step 1 - Download and install LAME MP3 codec. LAME MP3 encoder and decoder are essential tool to record and play your sound file in MP3 format.
Step 2 - Download and install Audacity - the versatile cross-platform sound recorder.
How to install programs in Linux? Read this article .
Step 3 - Play your sound file, or attach your sound source to Line in of your computer's sound card. Make sure that you can here the sound.
Step 4 - Start Audacity. Click the dropdown menu beside the Microphone icon, and select the input sound source. For example, if you want to record audio from external source such as CD / Cassette player, then select Line in. You can also choose Volume/Stereo Mix. Now start playing the music/sound that you want to record, and press Record button (the button with red circle) . For best results, experiment a little with sound input level.
Seep 5 - When done, click Stop button (the yellow square button). Now you can save your recording in wav file format. To record in other sound file format, you must have installed compatible sound encoder in your computer. For example, here, we want to save our recording in MP3 file format. Audacity needs LAME MP3 encoder, which we have already installed, and for the first time it may ask you to locate that file. Simply click on File menu and then go to Export as MP3. Audacity will then ask you to fill in MP3 tags, which you can supply, or you can skip this step, and click OK. Your recorded files will then be exported in MP3 file format.
Related: How to play MP3 files in Linux Fedora / Redhat