Linux – Play MP3 or WAV file via the Linux command line


I would like to make an alarm system backed by a Ubuntu (no graphical interface) box, which plays various announcement and alarm audio tracks (.mp3 or .wav) via the command line.

For example:

$ root> audioplay ./hello.wav

The audio should come from the PC audio jack. I might also wrap it with another socket listener (for example, Ruby Sinatra).

How can I do this?

Best Answer

mpg123 is a command-line utility which plays mp3 files. You can install it in Ubuntu with:

sudo apt-get install mpg123