0% found this document useful (0 votes)
15 views

youtube-dl_ Download YouTube Videos in Linux Command Line

Uploaded by

Erock
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

youtube-dl_ Download YouTube Videos in Linux Command Line

Uploaded by

Erock
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

Subscribe

Download YouTube Videos in Linux Command


Line Using youtube-dl
Easily download YouTube videos in Linux using youtube-dl command line tool. With this
tool, you can also choose video format and video quality such as 1080p or 4K.
Abhishek Prakash
16 Jun 2024 5 min read 182 Comments

There are various ways to download YouTube videos.

But when it comes to Linux, nothing beats youtube-dl. It is a command line based tool, so not
everyone's cup of tea. Still, it's a versatile tool that lets you do a lot more than just downloading
videos.

I use it to make backups of the videos I have uploaded on It's FOSS YouTube channel.
Membership

https://itsfoss.com/download-youtube-linux/ 1/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

In this tutorial, I will show you how to use youtube-dl to download videos from YouTube and
other websites. I'll also share a few additional examples that you may find useful.

What is youtube-dl?
youtube-dl is a Python-based command-line tool that allows downloading videos
from YouTube, Dailymotion, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles and a few
more similar sites. It is written in pygtk and requires Python interpreter to run this program, it’s
not platform restricted. It should run on any Unix, Windows or in Mac OS X based systems.

The youtube-dl tool supports resuming interrupted downloads. If youtube-dl is killed (for
example, by Ctrl-C or due to loss of Internet connectivity) in the middle of the download, you
can simply re-run it with the same YouTube video URL. It will automatically resume the
unfinished download as long as a partial download is present in the current directory. Which
means you don’t need download managers in Linux just for resuming downloads.

youtube-dl features
This tiny tool offers so many features that it won’t be an exaggeration to call it the best YouTube
downloader for Linux.
Download videos from not only YouTube but other popular video websites like
Dailymotion, Facebook etc
Allows downloading videos in several available video formats, such as MP4, WebM etc.
You can also choose the quality of the video being downloaded. If the video is available
in 4K, you can download it in 4K, 1080p, 720p, etc.
Automatic pause and resume of video downloads.
Allows to bypass YouTube geo-restrictions.

🚧 Attention! Downloading videos from websites could be against their policies. It’s up to
you if you decide to download videos. Furthermore, there is no release for this tool
because of various copyright issues of the past.

How to install youtube-dl on Linux


https://itsfoss.com/download-youtube-linux/ 2/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

youtube-dl is a popular program and, is available in the default repositories of most Linux
distributions, if not all. But unfortunately, you cannot use these standard packages in your
distribution. They are old and most probably don’t work. You can get a working youtube-dl either
from the official GitHub repository, or from the youtube-dl nightly release.

Install youtube-dl Nightly


youtube-dl offers a nightly release, which contains recent changes and fixes so that you can run
it without any error. I will describe the easiest way to set it up. First go to the Nightly release
GitHub page.

Download youtube-dl Nightly

Here, you can get a python file, named youtube-dl . Just download it. Once downloaded, copy
that file to /usr/local/bin/ . For this, open a terminal where you downloaded the file and
then run:

sudo cp youtube-dl /usr/local/bin/

Now, give the file the required permissions using the chmod command.

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

You cannot just run youtube-dl now, because of issue with python naming. It uses python
while in Ubuntu-based systems, it is python3 . So, you can create an alias for youtube-dl in
your .bashrc .

alias youtube-dl='python3 /usr/local/bin/youtube-dl'

That’s it. You have set up youtube-dl in your system.

Alternatively, compile from Git Master


https://itsfoss.com/download-youtube-linux/ 3/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

If you are running an Ubuntu-based Linux distribution, you can install the tools needed to
compile youtube-dl using the command below:

sudo apt install build-essential git

Now, clone the git repository and make the youtube-dl:

git clone https://github.com/ytdl-org/youtube-dl.git


cd youtube-dl/
make youtube-dl

Once you made youtube-dl, you need to copy it to a location in the path. Use the command
below:

sudo cp youtube-dl /usr/local/bin/

As in the previous case, if you run youtube-dl from the command line, you will get an error about
python because it tries to run using python while in Ubuntu, it is python3 . You can create an
alias on your .bashrc like:

alias youtube-dl='python3 /usr/local/bin/youtube-dl'

You can now use youtube-dl command.

Important: Keep your youtube-dl updated


Once installed, you can update it to the latest version using this command. This is helpful when
you have been using it for a few months:

youtube-dl -U

https://itsfoss.com/download-youtube-linux/ 4/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

team@itsfoss-mantic:~$ youtube-dl

Update youtube-dl

Using YouTube-dl for downloading videos


To download a video file, simply run the following command. Where, “VIDEO_URL” is the URL of
the video that you want to download.

youtube-dl <video_url>

team@itsfoss-mantic:~$ youtube-dl https://www.youtube.com/watch?v=WksxVLrALhg


[youtube] WksxVLrALhg: Downloading webpage

Download a Video

The video is saved in the directory from where you run the command.

Download YouTube videos in various formats and quality size


These days, YouTube videos have different resolutions, you first need to check available video
formats of a given YouTube video. For that run, youtube-dl with -F option. It will show you a
list of available formats.

youtube-dl -F <video_url>

Its output will be like:

https://itsfoss.com/download-youtube-linux/ 5/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

team@itsfoss-mantic:~$

Get Available Resolutions

Now among the available video formats, choose one that you like. For example, if you want to
download it in MP4 version and 1080 pixel, you should use:

youtube-dl -f 137 <video_url>

Download subtitles of videos using youtube-dl


First, check if there are subtitles available for the video. To list all subs for a video, use the
command below:

youtube-dl --list-subs <video_url>

To download all subs, but not the video:

youtube-dl --all-subs --skip-download <video_url>

Download entire YouTube playlist


https://itsfoss.com/download-youtube-linux/ 6/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

To download a playlist, simply run the following command. Where, “playlist_url” is the URL of the
playlist that you want to download.

youtube-dl -cit <playlist_url>

Download only audio from YouTube videos


You need ffmpeg installed on your system to download audio from videos. If not already
installed, open a terminal and run:

sudo apt install ffmpeg

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

youtube-dl -x <video_url>

The file format is M4A/Ogg, which you may not like. You can specify the file format of the audio
file in the following manner:
ON THIS PAGE
What is youtube-dl?
youtube-dl -x --audio-format mp3 <video_url>
youtube-dl features
How to install youtube-dl on Linux
Install youtube-dl Nightly
And a lot more can be done with youtube-dl
Alternatively, compile from Git Master
Important: Keep your youtube-dl updated
youtube-dl is a versatile
Using YouTube-dl commandvideos
for downloading line tool and provides a number of functionalities. No wonder
Download
it is such YouTube
a popular videos inline
command various
tool.formats and quality size
Download subtitles of videos using youtube-dl
Download entire YouTube playlist
I haveDownload
only shown somefrom
only audio of the most videos
YouTube common usages of this tool. But if you are keen to explore
itsAnd
capabilities
a lot morefurther, please
can be done withcheck its manual.
youtube-dl

I hope this article helped you to download YouTube videos on Linux. If you have questions or
suggestions, please drop a comment below.
https://itsfoss.com/download-youtube-linux/ 7/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

Tutorial

ABOUT THE AUTHOR

Abhishek Prakash
Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's
degree in Engineering and years of IT industry experience. Huge fan of Agatha
Christie detective mysteries 🕵️‍♂️

Featured

Black Friday Deals for Linux Users — 2024 Edition

This is the Coolest Raspberry Pi 5 Accessory I have Ever Used

Latest

9 Projects Ideas to Get into DIY Mode With Raspberry Pi Pico


30 Nov 2024

https://itsfoss.com/download-youtube-linux/ 8/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

FOSS Weekly #24.48: Archcraft, elementary 8 Release, Hyprland


Guides, New COSMIC Release and More
27 Nov 2024

ZimaCube Review: Almost Perfect Out of Box Homelab Experience in


Local Cloud Setup
27 Nov 2024

Become a Better Linux User


With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications,
explore new distros and stay updated with the latest from Linux world

Your email address

Subscribe

What's your reaction?

15 5 3 3 0 0
superb love wow sad laugh angry

182 Comments 18 ONLINE LOGIN

We welcome and encourage civil, courteous, and community-friendly comments.

Write your comment...

Newest
GrowleyMonster 5 months ago
Has it been fixed to work with Wayland?
0 0 Reply

Sreenath Team It's FOSS 5 months ago

https://itsfoss.com/download-youtube-linux/ 9/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

I am not sure about the issues with Wayland… I was running a Wayland
session, and it worked without any issues.
0 0 Reply

Cesar Jeopardy 1 year ago


youtube-dl has not worked for me for some time. My youtube-dl is already the
newest version (2021.12.17-2). Nor can update my current version. I think the
youtube-dl folks may have been shut down for legal reasons. Too bad, it was my
“go-to” Youtube downloader. It actually worked in some other web sites. An
outstanding piece of SW. Bummer, if it is gone for good!!!
0 0 Reply

Abhishek Plus Member ⭐ 1 year ago


youtube-dl has stopped development after copyright issues. You should try
using yt-dl instead.
0 0 Reply

Cesar Jeopardy 1 year ago


Thanks. Will try yt-dl.
0 0 Reply

Wolfgang Vogelbein 1 year ago


If you can read German, https://openjur.de/u/2466945.html tells you why
youtube-dl and its clone, yt-dl, are no longer working. They are prohibited to do
so, by court order.
0 0 Reply

Abhishek Plus Member ⭐ 1 year ago


That was expected
0 0 Reply

Andy 1 year ago


Not working anymore? ! Last update is from december 2021: youtube-dl is up-
to-date (2021.12.17)
. Getting errors like youtube_dl.utils.RegexNotFoundError: Unable to extract
uploader id
0 0 Reply

Abhishek Admin 1 year ago


Please use yt-dl. Will update this tutorial soon.
0 0 Reply

John 1 year ago


Using verbose :
https://itsfoss.com/download-youtube-linux/ 10/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

[debug] System config: []


[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--verbose',
u'https://www.youtube.com/watch?v=qrizmAo17Os']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref
UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 2.7.18 (CPython) - Linux-5.15.0-69-
generic-x86_64-with-Ubuntu-20.04-focal
[debug] exe versions: ffmpeg 4.2.7, ffprobe 4.2.7, rtmpdump
2.4
[debug] Proxy map: {}
[youtube] qrizmAo17Os: Downloading webpage
ERROR: Unable to extract uploader id; please report this
issue on https://yt-dl.org/bug . Make sure you are using the
latest version; type youtube-dl -U to update. Be sure to
call youtube-dl with the --verbose flag and include its
complete output.
Traceback (most recent call last):
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line
815, in wrapper
return func(self, *args, **kwargs)
File "/usr/bin/youtube-dl/youtube_dl/YoutubeDL.py", line
836, in __extract_info
ie_result = ie.extract(url)
File "/usr/bin/youtube-dl/youtube_dl/extractor/common.py",
line 534, in extract
ie_result = self._real_extract(url)
File "/usr/bin/youtube-dl/youtube_dl/extractor/youtube.py",
line 1794, in _real_extract
'uploader_id':
self._search_regex(r'/(?:channel|user)/([^/?&#]+)',
owner_profile_url, 'uploader id') if owner_profile_url else
SHOW MORE
0 0 Reply

Abhishek Admin 1 year ago


Are you using the latest version of youtube-dl?
0 0 Reply

John 1 year ago


yes of course. The error above is the result. I installed from the repo
(not the ubuntu repo) on ubuntu 20.04. I ended up trying yt-dlp and
that program worked.
https://itsfoss.com/download-youtube-linux/ 11/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line
0 0 Reply

Abhishek Admin 1 year ago


yt-dlp is good. Actually, youtube-dl is not being actively developed.
We’ll update our article.
0 0 Reply

Load More Comments

READ NEXT

Automounting External Drives in Linux

Exploring the Lightweight Alpine Linux in Virtual Box

Seamlessly Connect Your Android Phone and Linux Using GSConnect

Convert and Transfer PDFs and eBooks to Kindle Using Calibre

How to Check GPU Usage on Linux Systems

Become a Better Linux User


With the FOSS Weekly Newsletter, you
learn useful Linux tips, discover applications,
explore new distros and stay updated with
the latest from Linux world
Your email address

https://itsfoss.com/download-youtube-linux/ 12/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

SUBSCRIBE

https://itsfoss.com/download-youtube-linux/ 13/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

Making You a Better Linux User

Your email address

Subscribe

Navigation
📰 News Linux Server Side
📬 Newsletter En Español
🧩 Quizzes & Puzzles 🗳️ Feedback
🎒 Resources Impressum
🏘️Community
📖 About
🪪 Contact
📜 Policies

Resources
Courses 🎓
Distro Resources 📖
Guides 📒
Social
Facebook
Twitter
RSS
Instagram
Telegram
Youtube

©2024 It's FOSS. Hosted on Digital Ocean & Published with Ghost & Rinne. System

https://itsfoss.com/download-youtube-linux/ 14/15
12/1/24, 6:05 PM youtube-dl: Download YouTube Videos in Linux Command Line

https://itsfoss.com/download-youtube-linux/ 15/15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy