How to play MP3 by command line in Linux

Ever wondered if it's possible to play music from your Linux Terminal? That's the topic today! Let's show you various ways to play the MP3 audio files by command-line.

The Linux Terminal is one of the most powerful and reliable utilities one can get hands-on. You can use it to install packages and applications, execute programs, solve arising system issues, etc. But what would be more captivating than being able to play your mp3 music from the Terminal? Other than refreshment, there are situations where the Terminal is all you have to perform your tasks.

In this post, we will show you the various ways you can use to play your music from the command-line in Linux.

Play MP3 music via Command-Line

To get started, we will need to use several tools, most of which don’t come pre-installed. However, this shouldn’t worry you as we will give a detailed guide on how to install them in various Linux distributions

VLC to play mp3 music in command-line

VLC is one of the best and most popular media players. It supports a wide range of video and audio formats, making it the right choice for this post. However, we will not use the VLC – GUI (Graphical User Interface); instead, we will use the nvlc tool, the Ncurses interface of the VLC application.

Installing VLC in Ubuntu:

sudo apt update
sudo apt install vlc

To play an mp3 file in the command-line, launch the Terminal and execute the command below:

$ nvlc <file-name>
$ nvlc music-file.mp3

nvlc utility
nvlc utility

The Ncurses interface will open in the Terminal, and the mp3 file will start playing. You can even monitor it in the progress bar.

nvlc Ncurses interface
nvlc Ncurses interface

Like the VLC-GUI player, nvlc also comes with several control buttons ensuring you have an excellent experience. You can use Spacebar to pause your music and Left/Right arrow keys to forward or rewind your music.

If you have a directory full of music, you can play the entire playlist with the command below:

$ nvlc <path-to-your-directory>
$ nvlc /home/tuts/Desktop/MUSIC

nvlc to play Playlist
nvlc to play a playlist

The Ncurses window will open, showing your whole playlist.


Another VLC utility you use to play your music in the command line is cvlc. However, unlike nlvc, cvlc is simple, less verbose, and doesn’t use the Ncurses interface. To play a song with cvlc, execute the command below:

cvlc music-file.mp3


From the image below, cvlc is simple and lacks many exiting features.

cvlc dummy interface
cvlc dummy interface

MPG123 to play mp3 music using the command-line

Another popular utility for playing mp3 music in the command-line is mpg123. Unlike VLC, mpg123 comes pre-installed in several distributions. However, if it is not available for you, follow the steps below:

Install mpg123 in Ubuntu:

$ sudo apt update
$ sudo apt -y install mpg123

Install mpg123 Fedora:

$ sudo dnf install snapd
$ sudo ln -s /var/lib/snapd/snap /snap
$ sudo ln -s /var/lib/snapd/snap /snap

mpg123 comes with a lot more options that you can use. Execute the command below to see all of them.

mpg123 --help

mpg123 help command
mpg123 help command

To play an mp3 file using mpg123, execute the command below:

$ mpg123 music-file.mp3

mpg123 play music
mpg123 play music

To play all mp3 files in a directory, navigate to that particular directory using the Terminal and run the command below:

mpg123 *.mp3

mpg123 playlist
mpg123 playlist

Alternatively, you can shuffle your playlist with the -Z option. See the command below:

mpg123 -Z *.mp3

mpg123 shuffle songs
mpg123 shuffle songs

To view the entire list of all options, you can use with mpg123 utility, use the –longhelp command as shown below:

mpg123 --longhelp


FFplay is a built-in media player that comes with the FFmpeg media tools. FFmpeg is a powerful utility used not only to play media files but also to perform other numerous tasks. It doesn’t come pre-installed but is available for most Linux distributions.

Install FFmpeg on Ubuntu:

sudo apt update
sudo apt install ffmpeg

Install FFmpeg on Fedora:

sudo dnf -y install$(rpm -E %fedora).noarch.rpm
sudo dnf -y install$(rpm -E %fedora).noarch.rpm
sudo dnf -y install ffmpeg
sudo dnf -y install ffmpeg-devel

To play your mp3 file in the command-line with ffplay, execute the command below;

ffplay music-file.mp3

Your music will start playing, but you will see a GUI window pop-up display the spectrum analyzer.

ffplay spectrum window
ffplay spectrum window

If you don’t wish to have the spectrum analyzer window, include the -nodisp option in your command.

ffplay -nodisp music-file.mp3

ffplay show nodisplay
ffplay nodisplay

Like any other Linux tool, the ffplay comes wit a set of options that you can use while playing your music. You can see these options with the –help command.

ffplay --help

For example, if you don’t want ffplay to display the build config and license information banner, use the -hide_banner argument.

ffplay -nodisp -hide_banner music-file.mp3

ffplay hide banner
ffplay hide banner

Mplayer to play mp3 music on the command-line

Mplayer is another excellent utility we can use to play mp3 files in the Terminal. Even though this tool doesn’t come pre-installed, it is available for most Linux distributions. It also supports several control functions like the Spacebar for pause/play, Left/Right arrow keys to forward or rewind your music.

Install mplayer on Ubuntu:

$ sudo add-apt-repository universe
$ sudo apt update
$ sudo apt install mplayer MPlayer-gui

Install Mplayer on Fedora:

$ sudo dnf -y install$(rpm -E %fedora).noarch.rpm
$ dnf install mplayer

To play an mp3 file in the background with Mplayer, execute the command below:

mplayer music-file.mp3


If you have a directory full of mp3 files, you can play them with the *.mp3 command.

mplayer *.mp3

mplayer playlist
MPlayer playlist

If you are playing an extensive playlist, it would be nicer if you could shuffle through the list. Include the -shuffle flag in your command.

mplayer -shuffle *.mp3

mplayer shuffle
MPlayer shuffle

You can also repeat a single song as many times as you wish with the -loop argument. The command below will repeat that particular song 25 times.

mplayer -loop music-file.mp3

mplayer loop
MPlayer loop

Other essential options to use with the MPlayer are -gui and –nogui. Just like the name suggests, if you want to play a file with GUI, you will include the -gui parameter. If not, use -nogui.

mplayer -gui music-file.mp3
mplayer -nogui music-file.mp3

Those are but a few options you can use with the MPlayer utility. To view all of them, execute the command below:

mplayer --help

mplayer --help
MPlayer –help

Sox to play mp3 files in the command-line

Another powerful utility you can use to play mp3 files on your Terminal is Sox. Other than playing media files, Sox can convert various media file formats, record audio, and apply sound effects. This tool is available for most major distributions.

Install Sox on Ubuntu:

sudo apt update
sudo apt install sox
sudo apt install libsox-fmt-all

To play mp3 music with Sox, execute the command below:

play music-file.mp3


To play all the mp3 files in a directory, run the command below;

play *.mp3

Sox Playlist
Sox Playlist


Those are some of the best tools you can use to play mp3 files in the command-line. My favorite is VLC since it supports many media formats and comes with an intuitive Ncurses command-line interface. However, that shouldn’t limit your decision. Pick the tool that you feel comfortable with and enjoy your music.

Arun Kumar
Arun did his bachelor in computer engineering and loves enjoying his spare time writing for FOSS Linux. He uses Fedora as the daily driver and loves tinkering with interesting distros on VirtualBox. He works during the day and reads anything tech at night. Apart from blogging, he loves swimming and playing tennis.


Please enter your comment!
Please enter your name here





The year is 2020, and Linux-based operating systems have never been more popular. All thanks to their increased security and privacy, smooth updates, and open-source nature, everyone wants to at least give a shot to its multitude of distributions. Now we have already covered some of the best Linux-based laptops that you can find in the market as of now. With that being said, we get it that they are not everyone's cup of tea, so Linux PC desktops are also something that you should be taking a look at as well.
“I am because you are,” is the themed meaning behind the famed Ubuntu operating system. Moreover, this mindful phrase is practical because it continues to lure more individuals into the Ubuntu universe. Because great power beckons great responsibility, Ubuntu is stepping up. It realizes that different users will want to use the Ubuntu operating system software differently.

Linux Mint vs. Ubuntu – which is best for you?

The conundrum is that which one among them? The best solution is to try both of them out, and then choose whatever seems to work the best for your needs. But here, we're giving you some distinctions between the both that might make it easier for you to make a choice.

How to dual-boot Ubuntu and Fedora on your PC

Every Linux distribution has its capabilities and preferences as per the user requirements. That brings forth the need to run different distros on one laptop. For example, a CyberSecurity enthusiast might prefer to use Ubuntu for development and Kali Linux for penetration testing.

5 Things to do when your Linux system GUI freezes

All operating systems freeze at some point and, Linux distributions are no exceptions. In this post, we are going to look at five methods you can apply to your frozen system before thinking of plugging out the power cable or holding down the power button to power off the PC.

Best Laptops for Linux and Apps Development [2020]

Apart from your programming skills, there are a few other things that can also influence the way you code, and one of them is your computer system for sure. Even though it isn't like you can't code on a regular PC or laptop, speaking from personal experience, you can make the most out of your programming skillset by going for a computer with high specs and one that's been specially designed for such tasks.