How to play mp3 files from the Debian 10 command line

s2 0

If, like me, you want to use the command line to perform all tasks on Debian, you should also pay attention to how to use it to play audio, especially MP3. In this article we will explain how to install and use the famous Sox command line utility to listen to MP3s in your terminal.

Why the command line?

If you’re a terminal savvy person, you don’t want to leave the convenience of the command line and go elsewhere to do your daily tech activities. There is always a way to do almost all of our things right in the terminal. So why should it be any different when listening to music! Using the terminal makes certain tasks more efficient and even faster. The command line tools do not consume too many resources, making them great alternatives to the widely used graphical applications, especially if you are overwhelmed with older hardware.

We ran the commands and procedures mentioned in this article on a Debian 10 Buster system.

Install the Sox command line utility

Sox is easily available from the official Debian repository and can be installed from the command line using the apt-get command.

Open your terminal application using the system’s Application Launcher search as follows:

The Application Launcher can be accessed via the Super / Windows key.

The next step is to update your system’s repository index using the following command:

$ sudo apt-get update

This will help you to install the latest available version of any software from the Internet.

Please note that only an authorized user can add, remove and configure software on Debian.

You are now ready to install Sox. You can do this by running the following command as sudo:advertising

$ sudo apt-get install sox

Install Sox player

The system may ask you for the sudo password and also give you a Y / N option to continue the installation. Type Y then hit Enter; The software will be installed on your system. However, the process may take some time depending on your internet speed.

Please note that the above installation suggests that you manually install libsox-fmt-all after installing Sox. We highlighted this suggestion in the previous screenshot. With this library package, you can play all song formats on Sox. Please use the following command as sudo to install this package:

$ sudo apt-get install libsox-fmt-all

Install additional library for sox

Enter y when prompted with the ay / n option and the package will be installed and configured with Sox.

You can check the version number of the application and also check that it is actually installed on your system by running the following command:

$ sox --version

Check the SoX version

Playback of MP3 files via SoX

Playing MP3 files through Sox is pretty straightforward. In order to play a single mp3, use the following command syntax:

$ play ~/path/to/file/filename.mp3

For example, to play the SampleAudio_1.mp3 file from my music folder, I would run the following command:

$ play ~/Music/SampleAudio_1.mp3

Play MP3 file with SoX Player

You can exit the player while the song is playing by using the keyboard shortcut Ctrl + A. You can also play songs that are in a specific folder by going to that folder with the cd command and then using the play command as follows:

$ play filename.mp3

Sox lets you too play all mp3 files located in a single folder, one at a time, by the following command syntax:

$ play ~/path/to/files/*.mp3

For example, the following command will play all of the MP3 files in your music folder:

$ play ~/Music/*.mp3

Play music list

You can use the keyboard shortcut Ctrl + C to move to the next track. To exit the player, use Ctrl + CC.

Remove Sox

If you want to remove this command line music player from your system, run the following commands as sudo in your terminal.

$ sudo apt-get remove sox
$ sudo apt-get remove libsox-fmt-all

This was all about basic Sox usage. You can use the help command to learn everything else you can do with Sox!

How to play mp3 files from the Debian 10 command line