How to Download YouTube Videos on Linux Using yt-dlp

YouTube is the largest streamable media repository in existence, with tens of billions of online videos uploaded to the platform, and hundreds of thousands more added every day.

Although you can use browser extensions or online services to download videos from YouTube, it’s often faster, easier, and safer to download YouTube videos using a simple terminal tool. under Linux.

What is yt-dlp?

YouTube is the custodian of its online videos and doesn’t like people uploading them in a way that’s beyond the company’s control. The YouTube app lets you download some videos to your device so you can watch them offline, but they stay in the app and you won’t be able to play them using other software.

This is often inconvenient, as you may want to access or manipulate the file on other devices, or permanently add the YouTube video to your private collection.

We have already covered the best browser extensions to download youtube videos, however, Chrome extensions often pose a security risk because they have unrestricted access to all data that passes through your browser. Extensions can change ownership, allowing malicious actors access to your online life, and in some cases are even used to inject malware into your PC.

yt-dlp is a fork of youtube-dl and is a regularly updated open source tool that helps you download videos from your terminal. It is highly configurable and you can specify file type, resolution, etc. when downloading a video.

Although yt-dlp and its predecessor are designed for YouTube videos, the tool also works with hundreds of other video streaming sites, including a wide range of dedicated NSFW platforms. You can find a list of sites supported by yt-dlp at his GitHub page.

How to install yt-dlp on Linux

You can install yt-dlp by downloading the binaries, with pip, or by using a third-party package manager. The simplest and most widely applicable method is to use binaries. This method will work with all Unix-like operating systems, including Linux and macOS.

The following command will download the latest version of yt-dlp and copy it to your local path:

sudo wget https:

Now make it executable with:

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

Use yt-dlp to download YouTube videos on Linux

First, use your desktop browser to navigate to the YouTube video you want to download. Next, click in the browser bar to highlight the URL of the video you want to download, then copy it to your clipboard.

For our demonstration video, we chose “Glyn Moody: Walled Culture – A Journey Behind the Bricks of Copyright“. This video is licensed under a Creative Commons Attribution (Reuse Permitted) License. This is a CC BY 3.0 license that explicitly permits you to adapt, distribute, or reproduce the work, as long as you credit the author. original and provide a link to the license.

Once you have the URL, open a terminal and enter yt-dlp, followed by the URL you copied. In our case, we would write:

yt-dlp https:

when you knock Walk in, yt-dlp will download the video to your current directory using the default settings. For most people, this will be all you need.

Advanced use of yt-dlp

Although the default yt-dlp command is ideal in many situations, you can set dozens of configuration options to ensure you get exactly what you need. Here are some of the most useful.

Download YouTube videos in a specific format

By default, running the above command will download the desired video as a 1280×720 WEBM file. This is not always the case, and most of the time the default format will be an MP4 or 3GP file and the resolution can be anything.

The –list-formats flag shows you all formats available for download, available resolutions, file sizes and codecs used. In addition to downloading the full stream, you can specify to download only the video or audio stream.

yt-dlp --list-formats https:

Decide which format you want to download then use the -F argument and enter the appropriate ID.

For example, if you want to download only audio with an average bitrate of 129k, you would enter:

yt-dlp -f 140 https:

when you knock Walk inthe file will begin to download.

Alternatively, if you just want the best audio available and the best video available, merged into a single file:

yt-dlp -f 'bv*+ba' -o '%(id)s.%(ext)s'

Download an entire YouTube playlist as MP3 files

Often, YouTube videos are bundled into playlists and yt-dlp lets you download them easily. To download a YouTube playlist on Linux using the default settings, just put a playlist URL in place of an individual video URL.

It’s more likely that instead of a bunch of music videos, you just want the audio to be output as MP3 files. In this case, you must use additional arguments to specify the audio format: –audio-excerpt will extract audio from videos, –audio-format lets you specify the format of the downloaded audio, and –audio quality sets the bit rate.

yt-dlp --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist ''

…and that’s all you have to do.

Fake your location with a proxy

Some videos on YouTube and other sites are restricted to certain countries, usually due to licensing restrictions, and yt-dlp allows you to circumvent these restrictions in several ways.

You can use the –geo-check-proxy argument to specify a proxy address in a target country; the –geographical circumvention the argument will attempt to circumvent geo-restrictions by forging HTTP headers; –geo-bypass-country will simulate a two-letter country code.

These arguments will not always work on all sites. If one method doesn’t work, try another or consider a VPN.

yt-dlp offers a bunch of other configuration options

We’ve only scratched the surface of what you can do with yt-dlp, but we’re pretty confident it will meet the needs of most users. For a full list of available options and examples, see the official yt-dlp documentation.

You will definitely violate the terms of service by downloading YouTube videos using yt-dlp, but the legality of it is a gray area. Under US law, all works are instantly copyrighted as soon as they are produced, however, creators often waive their rights or license their works under the terms of Creative Commons, or assign a copyleft license.

Alternatively, some people and organizations, such as the US government, release their work into the public domain, which means anyone can use it for any purpose.

Another often overlooked aspect is that the DMCA prohibits the circumvention of copy protection technologies, which has effectively made it impossible to take advantage of copyright exceptions for almost all modern digital works. For a comprehensive guide to copyright law as it occurs in the United States and around the world, we recommend Glyn Moody’s”fortified culture” (CC BY 4.0).

Record the best YouTube content using yt-dlp

yt-dlp is one of our favorite tools for downloading videos and music from YouTube, but remember that you should only use it to download content that has a license that allows you to download it. TO DO.

Public domain works are still safe to use as you wish, while the exact terms of Creative Commons licenses vary by type. It’s worth taking the time to research what Creative Commons and copyleft licenses allow you to do.

Shirley K. Rosa