Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Download YouTube Videos in Linux Command Line

Rumi, August 3, 2020

Install youtube-dl to download YouTube videos in Linux terminal

youtube-dl is a Python-based small command-line tool that allows downloading videos from YouTube, Dailymotion, Photobucket, Facebook, Yahoo, Metacafe, Depositfiles and 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 has 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
  • Automatical pause and resume of video downloads.
  • Allows to bypass YouTube geo-restrictions

How to install youtube-dl on Linux

youtube-dl is a popular program and is available in the default repositories of most Linux distributions, if not all. You can use the standard way of installing packages in your distribution to install youtube-dl. I’ll still show some commands for the sake of it.

If you are running Ubuntu-based Linux distribution, you can install it using this command:

sudo apt install youtube-dl

The version in Debian/Ubuntu is usually old and you might face errors while downloading videos. However, I recommend installing it directly from its source repository.

For any Linux distribution, you can quickly install youtube-dl on your system through the command line interface with:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl

After fetching the file, you need to set a executable permission on the script to execute properly.

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

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

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>

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:

Setting language
BlXaGWbFVKY: Downloading video webpage
BlXaGWbFVKY: Downloading video info webpage
BlXaGWbFVKY: Extracting video information
Available formats:
37 : mp4 [1080x1920]
46 : webm [1080x1920]
22 : mp4 [720x1280]
45 : webm [720x1280]
35 : flv [480x854]
44 : webm [480x854]
34 : flv [360x640]
18 : mp4 [360x640]
43 : webm [360x640]
5 : flv [240x400]
17 : mp4 [144x176]

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 37<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

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

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 default file format is Ogg which you may not like. You can specify the file format of the audio file in the following manner:

youtube-dl -x --audio-format mp3 <video_url>

And a lot more can be done with youtube-dl

Administrations Configurations (Linux) Youtube

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes