How to play MP3 files from Debian 10 command line

If you, like me, like to perform all the tasks in Debian through the command line, you will also look for how to play audio, especially mp3, through it. In this article, we will explain how you can install and use the well-known Sox command-line utility to listen to mp3 files in your terminal.

Why command line?

If you are a terminal savvy person, you will not want to leave the command line and go somewhere else to perform any of your daily technical activities. There is always a way to do almost all of our things right in the Terminal. So why listening to music should be different! Using the Terminal makes certain tasks more efficient and even faster. The command line tools do not use too many resources and, thus, form excellent alternatives to widely used graphical applications, especially if you are stuck on old hardware.

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

Install Sox Command Line Utility

Sox is easily accessible through the official Debian repository and can be installed via the command line using the apt-get command.

Open the “Terminal” application through the system application search as follows:

Access to the Application Launcher can be obtained through the Super / Windows key.

The next step is to update the repository index of your system with the following command:

$ sudo apt-get update

Package Updates

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

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

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

$ sudo apt-get install sox

Install sox player

The system may ask you to enter a password for sudo, as well as provide the Y / n option to continue the installation. Type Y, then press Enter; software will be installed on your system. However, the process may take some time depending on the speed of your internet.

Please note that the above installation offers you to install libsox-fmt-all manually after installing Sox. We highlighted this proposal in the previous screenshot. This library package allows you to 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 y / n, and the package will be installed and configured using Sox.

You can check the version number of the application, and also make sure that it is actually installed on your system with the following command:

$ sox --version

Check SoX Version

Play mp3 files via SoX

Playing mp3s through Sox is pretty simple. In order to play one mp3use the following command syntax:

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

For example, to play the SampleAudio_1.mp3 file from the 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 playing a song using the keyboard shortcut Ctrl + A. You can also play songs located in a specific folder using the cd command to switch to that folder, and then use the play command as follows:

$ play filename.mp3

Sox also allows you play all mp3 files located in one folder, one after another, using the following command syntax:

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

For example, the following command plays all mp3 files in the Music folder:

$ play ~/Music/*.mp3

Music playlist

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

Remove Sox

If you want to remove this music player from the command line 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 is all about the basic use of Sox. You can use the help command to find out everything else you can do with Sox!

How to play MP3 files from Debian 10 command line

Related Posts