If you are addicted to the terminal and always find ways to do all kinds of things in the terminal, why not listen to music about it? The command line or terminal will provide everything you need in a more efficient and faster way, using fewer resources. It also becomes handier if you are using a headless version of your operating system.

In this article, we’ll look at some tools that allow you to listen to your favorite music directly from the command line. This can be useful in scenarios like the one described above. We will also explain how to install and use these tools and how to remove them if necessary.

We have run the commands and procedures mentioned in this article on a Debian 10 operating system.

Method 1: Using MOC

MOC or Music on Console is a Terminal based music player for Linux and UNIX operating systems. It is an easy yet powerful tool. All you need to do is to simply install the player, select the directory and start playing. MOC supports several audio file formats including mp3, OGG, Wave, SID, AAC, MIDI, Speex, WMA, DTS, and some others.

Launch the Terminal application in your Debian OS. For that, go to the Activities tab in the top left corner of the desktop. Then in the search bar, type terminal. When the Terminal icon appears, click on it to launch it.

Execute the following command in Terminal to revive the list of available packages:

$ apt-get update

Update packages

Then, we will need to install the MOC and MOC FFMPEG plugin that will help the moc player in recognizing many other audio formats. Execute the following command to do so:

$ apt-get install moc moc-ffmpeg-plugin

Install MOC Media Player

When the system prompt with a y/n option to continue the installation, enter Y to continue. It will take a while depending on your internet speed after that the software will be installed on your system.

In case you want to remove MOC player that was installed through this method, you can execute the following command in the Terminal:

$ apt-get remove moc moc-ffmpeg-plugin

Play music through MOC

Once installed, you can launch the MOC player from the Terminal using the following command:

$ mocp

Moc Terminal Media Player

You can then use the following keyboard shortcuts to control the music as you like:

  • P-for playing music
  • B-for playing the previous track
  • N- for playing next track
  • Q-for hiding the MOC interface
  • H-for help on using the player.

Method 2: Using mpg123

mpg123 is an open-source audio player that allows you to listen to music via command line. It supports MPEG audio formats, including MP3. It is only a console-based application with no graphical user interface.

The mpg123 utility is available in the package repository of Debian OS and we can easily install it through the command line using the apt-get command. Execute the following command in terminal to do so:

$ apt-get install mpg123

Install mpg123

When the system prompts with a y/n option to continue the installation, enter Y to continue. It will take a while depending on your internet speed after that the mpg123 player will be installed on your system.

To play the music, just navigate to the directory containing the music files and simply type mpg123 followed by the file name. Alternatively, if you do not want to navigate to any directory, just type mpg123 followed by the path to music file.

$ mpg123 <path/to/file>

Play Music with mpg123

If you ever want to remove mpg123 installed through this method, you can use the following command in the Terminal:

$ apt-get remove mpg123

Method#3 Using Sox

Sox is a very simple Terminal-based utility that converts various audio file formats into other formats. We can also play music through it. Sox is supported on all major platforms like Windows, Linux and macOS. It is available in official repositories of Debian OS. We can install it using the apt-get command. Execute the below command to do so:

$ apt-get install sox

Install Sox Media Player

Then execute the below command in Terminal to install the necessary codecs:

$ apt-get install sox libsox-ft-all

Install Codecs for Sox

When the system prompts with a y/n option to continue the installation, enter Y to continue. Wait for a while until all the required packages are installed.

To play music using sox, navigate to the directory where the music files are placed, and simply type play followed by music file name along with format.

$ play file_name

Use play command to play music files

That is all there is to it! I hop it will be helpful whenever you need to listen to music through your Terminal.

3 Music Media Players for the Debian 10 Terminal
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.