There are various ways to download a YouTube video; if you prefer a website, check out 9xBuddy. However, if you want to download YouTube videos on Linux using the command line, nothing beats yt-dlp.

What is yt-dlp?

yt-dlp is a free and cross-platform Python-based command-line tool that allows downloading audio and video from YouTube, Dailymotion, Facebook, Instagram, Reddit, Twitter, Udemy, Vevo, TikTok, and 1500+ other sites.

It's shipped as a standalone binary for Linux (armv7l = 32-bit and aarch64 = 64-bit), Windows (in ".exe" format), and macOS, and also offers an installation option via source compilation, which I personally wouldn't recommend to a beginner.

The features offered by yt-dlp include support for resuming interrupted downloads, changing video formats, SponsorBlock, cookie support, splitting videos by chapters, and many more. You can further enhance the features by using plugins; a few well-known plugins are YouTube Agegate Bypass and YouTube nsig Proxy.

How to Install yt-dlp on Linux

yt-dlp is not available in the Linux repository, but it can be easily installed using the standalone binary offered on the project page. So, if you are using Ubuntu 23.04, 22.04, or other Linux distributions such as Linux Mint, Fedora, Rocky Linux, openSUSE, Arch, and Manjaro, then visit the release files section in the project page and download the precompiled binary file.

downloading yt-dlp binary file for linux

When the download is finished, open your terminal, navigate to the downloads directory, and move the downloaded file to the user's bin directory using the following command:

$ cd ~/Downloads/
$ sudo mv yt-dlp_linux /usr/local/bin/yt-dlp

Output:

moving yt-dlp file to users bin directory

After moving the file, you need to set executable permissions for it to run properly.

$ sudo chmod a+rx /usr/local/bin/yt-dlp

Output:

setting executable permission in yt-dlp binary file

Once done, you're ready to use it, but make sure to execute the following command at least once a week to update it to the latest version.

$ yt-dlp -U

Usage of yt-dlp

Downloading videos is simple with yt-dlp, but if you want to perform some actions during or after the download, you can use the available options. Here, I'll show you how easily you can download a video with its additional options.

Download YouTube Video Using yt-dlp

To download a video file from your desired website, simply use the following command, with [VIDEO_URL] replaced by the URL of the video you want to download.

$ yt-dlp [VIDEO_URL]

The directory where you execute the command will store the video you download.

Download Audio Using yt-dlp

To download an audio file using yt-dlp, first install ffmpeg on your Linux system. Then, use the following command, replacing [VIDEO_URL] with the URL of the video whose audio you want to download.

$ yt-dlp -x [VIDEO_URL]

When issuing the above command, yt-dlp will first download the video in its original format, then use ffmpeg to convert it to an audio file before deleting it.

Download Subtitles of YouTube Videos Using yt-dlp

Before downloading subtitles (or captions in YouTube terminology), you need to first check if there are subtitles available for the video. For this purpose, you can use the following command to list all subs for a video:

$ yt-dlp --list-subs [VIDEO_URL]

If the subtitle is available, it will return an output similar to the one below:

Available subtitles for F6PqxbvX-X-:
Language Name                  Formats
ar       Arabic                vtt, ttml, srv3, srv2, srv1, json3
bn       Bangla                vtt, ttml, srv3, srv2, srv1, json3
zh-Hant  Chinese (Traditional) vtt, ttml, srv3, srv2, srv1, json3
en       English               vtt, ttml, srv3, srv2, srv1, json3
fr       French                vtt, ttml, srv3, srv2, srv1, json3
de       German                vtt, ttml, srv3, srv2, srv1, json3
hi       Hindi                 vtt, ttml, srv3, srv2, srv1, json3
id       Indonesian            vtt, ttml, srv3, srv2, srv1, json3
ja       Japanese              vtt, ttml, srv3, srv2, srv1, json3
ko       Korean                vtt, ttml, srv3, srv2, srv1, json3
pt       Portuguese            vtt, ttml, srv3, srv2, srv1, json3
ru       Russian               vtt, ttml, srv3, srv2, srv1, json3
es       Spanish               vtt, ttml, srv3, srv2, srv1, json3
th       Thai                  vtt, ttml, srv3, srv2, srv1, json3
tr       Turkish               vtt, ttml, srv3, srv2, srv1, json3
vi       Vietnamese            vtt, ttml, srv3, srv2, srv1, json3

To download your desired subs except the video itself, run:

$ yt-dlp --write-subs --sub-langs [Language] --skip-download [VIDEO_URL]

To download all subs except the video itself, run:

$ yt-dlp --all-subs --skip-download [VIDEO_URL]

Download Multiple YouTube Videos Using yt-dlp

To download multiple videos simultaneously using yt-dlp, you can either input all the video URLs, separated by spaces, into the following command:

$ yt-dlp [VIDEO_URL_ONE] [VIDEO_URL_TWO]

Alternatively, you can also create a text file, write the video URL, and assign the text file's path using the -a flag to the following command:

$ yt-dlp -a /path/to/the/textfile

Download Entire YouTube Playlist Using yt-dlp

To download the entire YouTube playlist, you can execute the following command, specifying either the playlist URL or playlist ID of the desired playlist for downloading.

$ yt-dlp [PLAYLIST_URL]

#OR

$ yt-dlp [PLAYLIST_ID]

Download YouTube Video in Various Format and Quality Size

Numerous formats and resolutions are available for YouTube videos, including mhtml, mp4, m4a, webm, 256x144, 1280x720, 1920x1080, and many more. So, use the -F flag to check the available formats and resolutions for your desired video.

$ yt-dlp -F [VIDEO_URL]

It will return an output like this:

ID     EXT      RESOLUTION   FPS CH
sb3    mhtml    48x27        0
233-0  mp4      audio only   0
249-0  webmp    audio only   0
140-0  m4a      audio only   0
602    mp4      256x144      15
136    mp4      1280x720     30
616    mp4      1920x1080    30

To download the video in your desired format and resolution from the list above, specify its ID with the -f flag in the following command:

$ yt-dlp -f 616 [VIDEO_URL]

How to Remove yt-dlp from Linux

To remove yt-dlp from your Linux system, simply delete the binary file from the user's bin directory using the command below:

$ sudo rm /usr/local/bin/yt-dlp

Wrap Up

yt-dlp is an amazing tool that has also been used by numerous popular GUI tools as a backend. However, such tools often become adversaries to websites, resulting in legal battles and leading to the discontinuation of the tool.

As of now, there's nothing of the sort happening around yt-dlp; you can use it, and if anything changes in the future, I'll inform you within this same article.