Ubuntu: Downloading YouTube videos


This article is part of a series of guest posts by Garikai Dzoma on helping new users migrate successfully to the Ubuntu operating system. Garikai started using Ubuntu Linux in 2007 and is an active member of the Zimbabwe Ubuntu LoCo team.

One of the good things about the good old Firefox 3 was that when in Ubuntu flash videos were downloaded to the /tmp directory. All you had to do was wait for the buffering to complete, minimize the Firefox window, got to the /tmp directory and copy and paste the video into the folder of your choosing. Playing the video is easy enough; vlc plays pretty much any format from .mp4 to .flv.

Imagine my shock when I visited YouTube using Firefox 4 for the first time  and could not find anything in the /tmp folder. After a lot of digging I found that the new browser uses a per user cache which is in the ~/.firefox  directory. After I spend 10 minutes exploring the tree I could still not find the video file and fuming I decided to Google  it. And then I met youtube-dl: the pedigree python based YouTube downloader.


I am aware that youtube-dl is in the repositories. However the upstream version is significantly up-to-date when compared with the version in the repositories. So the examples below are on the upstream version. If you want the easy way out just type the command:

  • sudo apt-get install youtube-dl

This is a command line program which works on all platforms including Windows and yet it is an amazing 103KB. To get youtube-dl:

  1. Visit the download page  in your browser and right click on the download link and select save as youtube-dl or
  2. Alternatively you can open the terminal and type the command:
  3. wget –tries=0

The first method saves the youtube-dl file in the ~/Downloads folder whilst the second method saves the youtube-dl file in the current directory most likely in the /home/user directory where user is the name of the current user. Preparing youtube-dl If you used the first method i.e. the browser method please open the terminal and type the command:

  • cd ~/Downloads/

This will take you to the directory where youtube-dl is i.e. this becomes the current directory. The following commands now apply to both method 1 and 2. Please note if you used method 2 above i.e. you used wget you should skip the cd ~/Downloads/ command above and follow the following commands.

  1. sudo chmod a+x youtube-dl
  2. This makes the file executable.

  3. sudo cp youtube-dl /usr/local/bin/
  4. This copies the youtube-dl file to the /usr/local/ directory where all locally installed and compiled programs are stored. This makes sure that the youtube-dl program is in everyone’s PATH i.e. any user on your system can now just type youtube-dl to access the program. Tip: In the command line you can save time by just typing yout and pressing the Tab key so the shell can autocomplete/expand the name.

  5. To download a video just open a terminal and type youtube-dl http://video.url where video.url is the web address of the video. For example youtube-dl this downloads a video to show you one of the reasons I love Ubuntu over Windows.
  6. The above command downloads the video into the current directory usually /home/usr. Open nautilus/dolphin or some other file manager and visit your home directory to copy the videos where you want them. You can use the pwd command to find the current directory in case it is not your home directory.
  7. Videos can be played using vlc/xine/totem/mplayer or any comatible video player of your choice. This works with other video sites too not just YouTube.
  8. Please check for regular updates. Whenever there is an update follow this guide from step 1 or 2 but before step 5 type the command:
  9. sudo rm -f youtube-dl

  10. Videos can be converted using ffmpeg.( I will be write a guide on this but the command man ffmpeg should give you a place to start.) ffmpeg can also extract audio from videos and convert them into mp3s.)  I must add that ffmpeg is a command line program also but several gui front ends exist.

Quick NetOne, Econet, And Telecel Airtime Recharge

You might also like

Mortal Kombat 2021, offers little else beyond the violence

Facebook rules that Trump remains banned in a far-reaching decision

Tecno appoints Captain America as its new brand ambassador

The digital divide that exists in Zim for people with disabilities