Download videos from YouTube

Youtube-dl is a brilliant small command-line program (for Linux) which enables quick and simple downloading of videos from YouTube and a several more sites (eg Facebook, Twitter, Vimeo, NBC, ABC, CNN, FOX NEWS, etc, see supported sites). It can even convert the videos to MP3’s within a single command.

To install

If you’re running MX-21, or other recent Debian-based operating systems, youtube-dl will be in their repository. To install, open a Terminal and type (or copy and paste):

sudo apt install youtube-dl

Yes, that’s it! You can start to download those videos now.

OR if it’s not in your repository, you should download directly from youtube-dl’s repository. Open a terminal and type and execute the following command (you can copy and paste), then press Enter:

sudo curl -L -o /usr/local/bin/youtube-dl

Then execute this command in your Terminal (to grant you permission to use it):

sudo chmod a+rx /usr/local/bin/youtube-dl

Downloading videos with youtube-dl

Youtube-dl is now installed on your system and you can download a video from YouTube (or elsewhere) by typing youtube-dl in a terminal, followed by a space and then the URL of the video. For example:


You will find the resulting video in whichever directory your terminal was in when you downloaded it, which, if you’ve just opened your terminal, will usually be your home folder. If you want to download a film directly into your Videos directory, you should change the directory in your terminal (eg:cd Videos) before downloading.

Convert YouTube videos to audio on-the-fly

If you want to extract the audio from a YouTube video in the form of an mp3, you can do this while downloading by adding a few options within the command. For example:

youtube-dl --extract-audio --audio-format mp3

Updating youtube-dl . . . very important!

Because of the way it installs independently, youtube-dl does not update along with other programs in your system. You will know when it needs updating because it will error when you try to use it to download a video from YouTube !! Remember this!! However, updating is simple. Just type sudo youtube-dl -U in your terminal and it should be fixed.

Be careful – case is very important when using the Terminal: -U and -u will do very different things!

Download an entire YouTube Playlist and convert it to MP3 tracks

And this is amazing! The code below will download your chosen playlist from youtube, then strip all the video and convert each track to good quality MP3’s.

Just copy the code into a Terminal, and replace the URL in the code with the URL in the browser address bar of your chosen youtube playlist.

(The mp3 tracks will be saved in whichever directory your Terminal is in, so if you want them to save directly into (for example) your Music folder, you must change the Terminal directory to Musiccd Music before you issue the command.

youtube-dl --ignore-errors --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist '

More you-tube-dl options and commands

Youtube-dl is extremely versatile; there are loads of options which can be found at their github page here: