Download music to mp3 with the command line in Linux

in linux •  9 months ago

Download mp3's on the Linux Command Line? What?

What is this post about? This post is to show how you can download music from youtube or soundcloud using the CLI. Before I got into Linux I was always wondering, what is so cool about the command line, and why would I want to use it for everything?

Besides the above meme, I've also felt a bit like:"I'm on this Linux thing, what now?". Its almost like the first time you installed Gentoo. Now what?

Download videos from youtube and have them converted to mp3 automatically:

For this example we are going to download one of my favourite Dave Chapelle videos.
Start by installing youtube-dl:
(You could do all of this in a virtualenv if you know what that is, if you don't know yet, don't worry about it for now.)

$ sudo apt-get install python3-pip

$ sudo pip3 install youtube-dl

You should now have youtube-dl installed. You can check if it was installed with:

$ which youtube-dl

Now we navigate to the directory where we would like to download the video as an mp3:

$ cd ~/Music/

Now let's download the video which contains a cool song in my opinion:

$ youtube-dl -x --audio-format mp3

Hope this short post is of some help to somebody out there. If you would like to know how to download via the CLI from soundcloud then leave me a comment and I'll explain how you can do it.
Thanks for reading. Please follow and upvote if you enjoyed this article.

I wrote a previous post on this: and one of the users @harvhat gave a cool suggestion that I included in this post.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Oh my daughter is going to love this - she watches cover artists on YouTube and has often wanted the music on her phone


I do that for music in my car. You can show her scdl too (soundcloud downloader in python) ,see which can be installed with:
$ pip3 install scdl

Youtube-dl is great, did you know about hooktube ? It is really nifty
replace in any url with and you can watch the video without ads and through the browsers native video player!


I am going to try hooktube(I hope its not a lemonparty type site waiting for me lol).
Thanks for the info. Btw I see you like chess. What is a good site to read about chess related stuff,besides


Ok hooktube is cool I tried it out

I always download audio in OPUS format with youtube-dl if I can.
youtube-dl --list-formats
OPUS is better quality and size than the m4a of vorbis formats.
If you want to see videos without ads: Opening the URL in VLC usually works.


Very interesting comment about OPUS. I used to be on then I would download stuff in FLAC never heard of OPUS before. I only recently figured out the opening a URL in VLC thing.
Thanks for sharing!