Youtube-dl Command Line Utility Download Anything And Everything

Youtube has become an indispensable source of sharing video content on the internet. There are numerous tools available for Windows which allow you to download youtube videos to your home desktop or laptop. But in this article, we’ll show you how to install and use youtube-dl command line based tool that allows you to download youtube videos in Linux. Although we’ll be using youtube-dl in Linux, installers for Windows and MacOS are also available. A GUI version of the software named youtube-dl-gui is also available.
The utility youtube-dl is open source and is written in python.

Some of the features of youtube-dl are highlighted below:

  • It’s free and open source
  • It’s a cross-platform tool (available for Linux, Windows, and MacOS)
  • Very easy to install and use
  • Videos can be downloaded in a wide range of formats
  • Allows entire video playlists to be downloaded in a single command invocation

youtube-dl  command Installation

Use curl or wget to download the youtube-dl binary directly to our system.  For the purpose of this demonstration we’ll be using wget as shown

root@arkit-centos ~]# wget

100%[================>] 1,596,414 233KB/s in 7.8s

2017-11-27 09:46:32 (199 KB/s) - ‘youtube-dl’ saved [1596414/1596414]

The above command downloads the binary to my current working directory. We’ll move it to /usr/bin directory before using it.

[root@arkit-centos ~]# mv youtube-dl /usr/bin

In case you feel that you are working on a minimal type installation of Linux and might end up missing some dependencies, then you can use a package manager to download the binary.

For Red Hat based systems type

yum install youtube-dl

Note:  youtube-dl is found in the EPEL repository so you need to have it enabled for the above mentioned yum command to work.

For Debian based systems type:

apt-get install youtube-dl

Note: In case you are working on a Debian based system, we strongly suggest you to use apt-get because we found many dependencies to be missing.

Now that we’ve downloaded the package, change the ownership of the downloaded file to make it executable.

[root@arkit-centos ~]# ls -l /usr/bin/youtube-dl
-rw-r--r--. 1 root roat 3 Nov 27 09:26 /usr/bin/youtube-dl
[root@arkit-centos ~]# chmod +x /usr/bin/youtube-dl
[root@arkit-centos ~]# ls -l /usr/bin/youtube-dl
-rwxr-xr-x. 1 root roott 3 Nov 27 09:26 /usr/bin/youtube-dl

To view the version of youtube-dl installed we use the –version option with the command.

[root@arkit-centos ~]# youtube-dl --version

That is all for the installation part. We’ll now proceed to downloading some videos from youtube.

Download videos using youtube-dl

To download a video from youtube using youtube-dl we simply need to type the command followed by the video URL.

[root@arkit-centos ~]# youtube-dl
[youtube] hmNeKv-_dWc: Downloading webpage
[download] Destination: Fight Night MySQL vs Postgres-hmNeKv-_dWc.webm
[download] 100% of 9.72MiB in 00:41

Above command downloads the video to my current working directory.

[root@arkit-centos ~]# ls -ltrh Fight\ Night\ \ \ MySQL\ vs\ Postgres-hmNeKv-_dWc.webm
-rw-r--r--. 1 root raot 9.8M Jun 24 2012 Fight Night MySQL vs Postgres-hmNeKv-_dWc.webm

Default file format of the downloaded video file is wbem.

Choose desired format while downloading videos

To list the available formats for downloading the video we use the –list-formats option.
Note: that using this option while using the youtube-dl command will only show you the available video formats and will not download anything.

[root@arkit-centos ~]# youtube-dl --list-formats

Options for selecting the desired video format/quality are presented to us in the form of format codes in the above output
To download video using one of the mentioned codes we use the -f option with the youtube-dl command followed by the format code and the video URL

[root@sahil-centos ~]# youtube-dl -f 18
[download] Destination: How to Reset Forgotten Ubuntu Administrative Password-tzr_e1KiaRA.mp4
[download] 100% of 3.12MiB in 00:10

The video I just downloaded is in fact from our Linux tutorial youtube channel.
Please do subscribe to it for easy to follow video tutorials on Linux.

Download multiple videos with single command

We can supply a list of URLs to the youtube-dl command and download multiple videos simultaneously

To demonstrate this feature I’ve created a text file and added two URLs in it

[root@arkit-centos ~]# cat url.txt

These are the URLs of the videos that I would like to download.
To download all the videos corresponding to the URLs mentioned in the text file, use the youtube-dl command with the -a option followed by the text file as shown below.

[root@arkit-centos ~]# youtube-dl -a url.txt

This has now downloaded both videos successfully.

[root@arkit-centos ~]# ls -ltrh RHEL*
-rw-r--r--. 1 rootroot 14M Aug 11 2016 RHEL7 - reset root password-4HDjOh-l7hE.mp4
-rw-r--r--. 1 root root 4.7M Sep 1 2016 RHEL 5 - root password reset-xv9zA2d_YbU.mp4

Download videos from (LinkedIn Learning) is a popular online learning content provider and premium paying members can use youtube-dl to download videos from the site. If you are not a paying member then you’ll be able to download the freely available videos only.
To use this you need to supply the URL of the course you would like to download.

Here’s a quick example

[root@linuxnix ~]# youtube-dl --cookies cookies.txt
[lynda:course] 601768: Downloading course JSON


In addition to the examples, we’ve demonstrated in this article, youtube-dl command offers a plethora of other features and options. You may use youtube-dl with the –help option to view a full listing of the available options. We encourage you to explore them further and as always we welcome your feedback and suggestions.

Related Articles

awk scripting explained with practical examples

NCSA Certification Guide

Introduction to Linux Shell Scripting video Tutorial

Thanks for your wonderful Support and Encouragement