YouTube is the biggest repository of streamable media in existence, with tens of billions of videos online uploaded to the platform, and hundreds of thousands more added every day.
While you can use browser extensions or online services to download videos from YouTube, it’s often quicker, easier, and safer to download YouTube videos using a simple terminal tool on Linux.
What Is yt-dlp?
YouTube is the guardian of its online videos and doesn’t like people downloading them in a way that is beyond the company’s control. The YouTube app allows you to download some videos to your device so you can watch them offline, but they remain within the app and you won’t be able to play them using any 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’ve previously covered the best browser extensions to download YouTube videos, however, Chrome extensions are often a security risk as they have unrestricted access to all data which passes through your browser. Extensions can change ownership, allowing bad 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 to download videos from your terminal. It’s highly configurable, and you can specify the file type, resolution, and more while downloading a video.
Although yt-dlp and its predecessor are designed with YouTube videos in mind, the tool also works with hundreds of other video streaming sites—including a huge range of dedicated NSFW platforms. You can find a list of sites supported by yt-dlp on its GitHub page.
How to Install yt-dlp on Linux
You can install yt-dlp either by downloading the binaries, with pip, or using a third-party package manager. The easiest 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 yt-dlp release, 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’ve chosen “Glyn Moody: Walled Culture—A Journey Behind the Copyright Bricks“. This video is licensed as Creative Commons Attribution license (reuse allowed). This is a CC BY 3.0 license which explicitly allows you to adapt, distribute, or reproduce the work, so long as you credit the original author, 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 enter:
When you hit Enter, yt-dlp will download the video to your current directory using default settings. For most people, this will be all you need.
Advanced yt-dlp Usage
While the default yt-dlp command is great in many situations, there are dozens of configuration options you can set, 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 video we want as a 1280×720 WEBM file. This is not always the case, and most times the default format will be an MP4 file or 3GP and the resolution could be anything.
The –list-formats flag shows you all the formats available to download, the resolutions available, the file sizes, and the codecs used. In addition to downloading the complete stream, you can specify to download the video or audio stream only.
yt-dlp --list-formats https:
Decide which format you want to download then use the -f argument and enter the appropriate ID.
For instance, if you want to download audio only with an average bit rate of 129k, you should enter:
yt-dlp -f 140 https:
When you hit Enter, the file will start downloading.
Alternatively, if you just want the best available audio and the best available video, merged into a single file:
yt-dlp -f 'bv*+ba' https://www.youtube.com/watch?v=f6wtF_2eyrU -o '%(id)s.%(ext)s'
Download an Entire YouTube Playlist as MP3 Files
Often YouTube videos are grouped into playlists, and yt-dlp lets you download them easily. To download a YouTube playlist on Linux using the default settings, simply 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 outputted as MP3 files. In this case, you need to use additional arguments to specify the audio format: –extract-audio will extract the audio from the videos, –audio-format allows you to specify the format for the downloaded audio, and –audio-quality sets the bitrate.
yt-dlp --format bestaudio --extract-audio --audio-format mp3 --audio-quality 160K --output "%(title)s.%(ext)s" --yes-playlist 'https://www.youtube.com/watch?v=_AnGd4PaG6U&list=PLmbToKnvW413vfHySE8AKb4i6bPnU92F7'
…and that’s all you need 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 bypass these restrictions in several ways.
You can use the –geo-verification-proxy argument to specify a proxy address within a target country; the –geo-bypass argument will attempt to bypass geographic restrictions by faking HTTP headers; –geo-bypass-country will fake 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 fairly confident that it will meet the needs of most users. For a complete list of available options and examples, check out the official yt-dlp documentation.
Is It Legal to Download YouTube Videos?
You will certainly be breaching the terms of service by downloading YouTube videos using yt-dlp, but the legality of it is a gray area. Under US law, all work is instantly copyrighted as soon as it’s produced, however, creators often waive their rights or license their works under Creative Commons terms, or assign a copyleft license.
Alternatively some individuals and organizations—such as the US Government— release their work into the public domain, meaning that anyone can use it for any purpose.
Another oft-overlooked aspect is that the DMCA bans circumvention of copy-protection technologies, which has made it effectively impossible to take advantage of copyright exceptions for nearly every modern digital work. For an exhaustive guide to copyright law as it stands in the US and worldwide, we recommend Glyn Moody’s “Walled Culture” (CC0 1.0).
Save 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 permitting you to do so.
Public domain works are always safe to use however you wish, while the exact conditions 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.