Install youtube-dl on Ubuntu 20.04

The youtube-dl a tool for downloading videos from YouTube and other websites via command line. The list of all the supported websites can be found in official website. The youtube-dl is a cross-platform tool that requires the Python interpreter.

This tutorial explains how to install youtube-dl on Ubuntu 20.04.

Install youtube-dl

Download youtube-dl from official website to the /usr/local/bin directory:

sudo wget -qO /usr/local/bin/youtube-dl https://yt-dl.org/downloads/latest/youtube-dl

Set read and execute permissions for a file:

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

Now youtube-dl will available for all users as a system-wide command.

We can check youtube-dl version as follows:

youtube-dl --version

If you get an error message /usr/bin/env: 'python': No such file or directory, you need to create a symbolic link for /usr/bin/python because Ubuntu 20.04 only has Python 3 by default.

sudo ln -s /usr/bin/python3 /usr/bin/python

Once created symbolic link, you can check youtube-dl version again.

To update youtube-dl to the latest version, use the following command:

sudo youtube-dl -U

Testing youtube-dl

Video from website can be downloaded as follows:

youtube-dl <VIDEO_URL>

The <VIDEO_URL> is a video URL that you want to download. For example:

youtube-dl https://www.youtube.com/watch?v=C0DPdy98e4c

In most cases, you don’t need to install any external dependencies for youtube-dl. However, if you want to convert video/audio, you will need to install FFmpeg. See a post how to install it.

The -x option can be used to convert video files to audio only files. This feature requires FFmpeg.

youtube-dl -x https://www.youtube.com/watch?v=C0DPdy98e4c

Uninstall youtube-dl

If you want to remove youtube-dl, run the following command:

sudo rm -rf /usr/local/bin/youtube-dl

Leave a Comment

Your email address will not be published. Required fields are marked *