Download and Watch YouTube videos from Linux Shell Prompt

Publishing your own video on YouTube, or watching other people’s videos, is all the rage these days. Why are we talking about YouTube, in a column about the CLI? Because this week we’re writing about youtube-dl, a clever little CLI tool that’s easy to install and and use to fetch YouTube videos.

Youtube-dl is a Python script, licensed under the “non-copyleft” free software MIT/X11 license. It is not platform-specific; it can run under Linux, Mac OS X, or Windows platforms so long as a recent — 2.4 or later — version of Python is installed. It is a small command-line program to download videos from and a few more sites. It requires the Python interpreter (2.6, 2.7, or 3.3+), and it is not platform specific. It should work in your Unix box, in Windows or in Mac OS X. It is released to the public domain, which means you can modify it, redistribute it or use it however you like.

Update: Check out this bash script – it does same thing without using python.

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
26 comments… add one
  • Davide Mirtillo May 6, 2011 @ 7:39

    I think you should update the article, the project has apparently moved to github:

  • Rafael Soares Apr 8, 2011 @ 17:53

    There’s a new script for linux to search and watch youtube’s video on linux shell, called YouShell.

  • phar0z Sep 14, 2009 @ 20:24
    # checking whether you have youtube-dl
    if [ ! -x `which youtube-dl`  ];then
    echo “Error! youtube-dl isn’t installed.”
    exit 0
    #checking whether you have vbrfix
    if [ ! -x `which vbrfix`  ];then
    echo “Error! vbrfix isn’t installed.”
    exit 0
    #download video(s)
    for URL in $*; do
    youtube-dl -t “$1&fmt=18″
    for VIDEO in `ls *.flv`; do
    ffmpeg -i $VIDEO -acodec copy $OUTPUT
    #move video
    mv $OUTPUT /home/$USER/music
    vbrfix /home/$USER/music/$OUTPUT /home/$USER/music/$OUTPUT
    rm -rf vbrfix.log vbrfix.tmp
    rm -rf $VIDEO
    echo “Done.”
  • xijhing Aug 18, 2009 @ 5:16

    usage: utube NAME youtubeurl

    if [ $# -ne 2 ]
    echo “Usage : $0 ”
    echo “e.g : $0 steve_jobs”
    todnload=$(youtube-dl -g -b $2 | xargs wget –spider 2>&1 | grep Location: | awk '{print $2}')
    #echo -e “Got the file…n$todnload”
    axel $todnload -q -o ~/$1.flv
    echo “Download Completed…”
    ffmpeg -i $1.flv -r 50 -ar 48000 -ab 196000 -b 300k -croptop 0 -cropbottom 0 -cropleft 0 -cropright 0 $1.mp4
    echo "Cleaning up..."
    rm ~/$1.flv
    rm ~/videoplayback?ip*
    echo "Done! Enjoy watching $1"
  • Jim Bowe Dec 17, 2008 @ 13:36

    Good script to do this in bash here:

    Works with the latest YouTube versions. (As of December 2008)

  • Webdesign Nov 26, 2008 @ 15:19

    Nice youtube script, thanks so much!


Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.