How to download a video from YouTube on Ubuntu

If you ever find yourself stuck with a slow Internet connection or capped bandwidth and a YouTube video you just want to watch again and again, then downloading the YouTube video is tempting. Well good news, now you can!The software is called youtube-dl and runs from the command line. Unfortunately, the version found in the Ubuntu Karmic (and previous) repositories is out-of-date and broken due to modifications to the YouTube API.But despair not, the issue is fixed in the most recent release of youtube-dl. Better yet youtube-dl consists of a single Python script and is easy to install from source. Here’s how.First make sure you have Python and Mercurial installed. Open a terminal and typesudo aptitude install mercurial python
Also make sure that the outdated version of youtube-dl is removed if previously installed.
sudo aptitude remove youtube-dl
Now fetch the youtube-dl source from the web. hg clone
Enter the source directory
cd youtube-dl
and copy the Python script to a location where the system can find it
sudo cp youtube-dl /usr/local/bin/
And that’s it! In order to download a video from YouTube you must start watching the video on Then copy the URL of the video to the clipboard and type in a terminal
youtube-dl url-on-youtube-dot-com
where url-on-youtube-dot-com is the URL you copied from YouTube. The video should now start downloading. The downloaded video will be in Flash Video format (.flv) and can be viewed using e.g. vlc.

3 Replies to “How to download a video from YouTube on Ubuntu”

  1. The updated release of youtube-dl is now in the Ghabuntu PPA at .

    The easiest way to add the repository is by typing the two commands

    sudo add-apt-repository ppa:ghabuntu/ghabuntu

    sudo apt-get update

    in a terminal. Make sure any previous version of youtube-dl is removed with

    sudo apt-get remove youtube-dl

    before installing the one from the PPA with

    sudo apt-get install youtube-dl

Leave a Reply

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