How to Download YouTube Videos with Linux Command?

Install youtube-dl to command YouTube videos to the Linux terminal

youtube-dl is a Python-based, small command-line tool that allows you to download videos from YouTube, Dailymotion, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles, and many more.

Main features of youtube-dl

This little tool has so many features that we can call it the best YouTube video download application for Linux.

  • Not only from YouTube, Dailymotion, Facebook, etc. Download videos from other popular video sites.
  • MP4, WebM, etc. It allows you to download videos in various video formats such as.
  • You can also choose the quality of the downloaded video. If the video is available in 4K, 4K, 1080p, 720p etc.
  • Automatically pause and resume video downloads.
  • YouTube allows bypassing geographical restrictions

How to install Youtube-dl?

If you are using a Ubuntu-based Linux distribution, you can install it using the command below:

For other Linux distributions, you can also install youtube-dl on your system via the command-line interface:

After receiving the file, you need to set executable permission in the script for it to work properly.

Let’s use YouTube-dl to download videos:

The following command is sufficient to download the video. “VIDEO_URL” is the URL of the video you want to download.

You can also download YouTube videos in different quality and genres.

It will be enough to use the command below to see the existing formats of the Youtube video. This will show us a list of the available formats.

The output will be as follows:

Now we can choose the format you want. For example, if you want to download it in MP4 version and 720 pixels, it should be done as follows:

Now download subtitles of videos using Youtube-dl.

First, check if there are subtitles for the video. Use the following command to list all the subsections of a video:

To download all sub videos, but to download the video:

Download the entire YouTube playlist

Just run the command below to download a playlist. “Playlist_url” is the URL of the playlist you want to download.

Download audio from YouTube videos only

If you only want to download the audio from a YouTube video, you can use the -x option to extract the audio file from the video.

The default file format is downloaded as Ogg. You can change the file format of the audio file as follows:

I hope it was a useful article.