How To Download Youtube Videos in Linux in Desired Format

In this tutorial I will show you how you can download Youtube videos in your desired format, batch download videos from a file, or extract the audio only from the downloaded video in Linux (Ubuntu, Fedora Arch Linux etc).

As everyone knows Youtube is the largest source of online videos in the world. There are many Youtube Video downloaders available in Windows platform, but most of them don’t work or are slow or require you to pay for downloading videos. Today I will show how you can download a Youtube  video  in  your  Linux  machine  for free also in desired format using a open source software known as youtube-dl. This will work on all popular Linux distros such as Ubuntu, Fedora, Arch Linux, Linux Mint etc.

Installing youtube-dl

Check your distro’s repositories if youtube-dl is available there. For Debian based distros such as Ubuntu or Linux Mint, you can use the following command.

For RPM based

Arch Linux users can use pacman to install it as follows


You can also compile from source by downloading it from this page.

Using youtube-dl : Downloading videos, Pausing and Resuming downloads

To download a video, go to and search the video you want to download. Open the video page and copy the URL from the address bar as shown below.

Copying Youtube URL

Make sure you have installed youtube-dl using the above steps. Issue the following command to start downloading the video

eg. if the video URL is, type

You will see some information as shown in the screenshot below, after which the video will start downloading and you will see the current speed and time remaining.

Downloading Youtube videos using youtube-dl

To pause or cancel the download, use Control-C. You can resume downloading the video using the following command

youtube-dl -c

Batch Downloading Youtube Videos from a file

You can also write URLs of the videos in a file to be downloaded and issue a single command to download it at once. To do that, search all the videos you want to download and copy paste the URLs in a text file, each URL in a separate line. Then issue this command to download all the videos at once. This is especially useful if you want to download a lot of videos and don’t have time enough to issue the command separately.


Where filename.txt is the file where the video URLs are saved.

Batch Download Youtube videos from a file -youtube-dl

Downloading Youtube videos in Preferred format

Often it may happen that you may want to download a video in a format different from the default one, or in a different resolution. To know what format a video is availiable, use the following command.

youtube-dl -F

Make sure you typed capital F. It will display the formats and resolutions the video is available in and their specific code in the first column.

Download video in a different format – youtube-dl
To download the file in your preferred format, type

Eg. I want to download the file in .flv format with resolution 240×400, so I use this command

youtube-dl -f 5

The lower the resolution, the smaller will be the size of the file hence will save your data usage. By default, youtube-dl downloads the file in the best quality format.

Extracting Audio of Youtube Videos

If you just want the audio of the youtube video, you can issue this command to get it. The default is 128kbps. If you want to keep the video file too after the audio has been extracted, you can use the -k option. Hence all together to download my video and extract the audio in mp3 format with a bitrate of 176kbps and keep the video, I use:

youtube-dl –audio-format mp3 –audio-quality 176 -k

For more options, type

youtube-dl -h

Facebook Comments

Sunit Kumar Nandi

Sysadmin, coder, e-magazine editor, tech reviewer, freelancer. I love science and all things nice.

You may also like...

23 Responses

  1. Hojune Kim says:

    cool! This was the only method that actually worked!

  2. Lee says:

    Thanks! Works great. FYI: as of right now (01-28-2013) there is a problem. Youtube changed something to make it incompatible with youtube-dl, it’s been fixed in the latest version. According to this post you will need to do the following to update youtube-dl until the package system gets the updated version (i.e., you will need to do it a few times):

    sudo youtube-dl -U

  3. Anonymous says:

    Thank a lot it worked perfectly

  4. But I receive error message…
    Unable to download video

  5. Not Working :
    [youtube] Setting language
    [youtube] Yc0CVEuUvRs: Downloading video info webpage
    [youtube] Yc0CVEuUvRs: Extracting video information
    ERROR: format not available for video

  6. where will be the downloaded file

  7. Anonymous says:

    Great, tnx!!

    Simple and easy solution in one step concerning extracting audio from youtube video!

  8. satya says:

    Though downloading youtube videos is not legal and it’s not permitted by youtube but if you and i were producers ,we can follow youtube downloading only if intended for fair use also you gona find many videos which is under creative common license and reuse is permitted.So you can download those kind of videos and also reuse it.You can follow the above method for downloading videos or here is the youtube downloader which i use.

  9. Alex Jones says:


    Though downloading YouTube videos is not legal & it’s not permitted by YouTube but If you and I were producers,we can allow YouTube downloading only if intended for fair use. Also you gonna find many youtube videos which is under creative common license and reuse is permitted. So you can download those kind of videos and also reuse it.
    You can follow the above method for downloading videos or here is the youtube downloader which I follow

  10. [root@localhost ~]# youtube-dl
    [1] 4298
    [root@localhost ~]# [youtube] Setting language
    [youtube] watch: Downloading video webpage
    ERROR: unable to download video webpage: HTTP Error 404: Not Found

  11. Anuj says:

    To download youtube videos is very simple, all you need id type in “ss” just after leaving www. in the url of the video and then click enter and doing this will redirect you to where you can choose the format of the video and your video will start downloading. Know here How to download youtube videos

  12. Hi Thanks worked great but ummm where do I find the file after it’s downloaded…please be kind I’m a grand dad…newbie

  13. John says:

    I am getting the following error:

    [youtube] Setting language
    [youtube] Ym1-rI0SdaA: Downloading video webpage
    [youtube] Ym1-rI0SdaA: Downloading video info webpage
    [youtube] Ym1-rI0SdaA: Extracting video information
    Traceback (most recent call last):
    File “/usr/lib/python2.7/”, line 162, in _run_module_as_main
    “__main__”, fname, loader, pkg_name)
    File “/usr/lib/python2.7/”, line 72, in _run_code
    exec code in run_globals
    File “/usr/bin/youtube-dl/”, line 7, in
    File “/usr/bin/youtube-dl/”, line 536, in main
    File “/usr/bin/youtube-dl/”, line 520, in _real_main
    File “/usr/bin/youtube-dl/”, line 475, in download
    File “/usr/bin/youtube-dl/”, line 80, in extract
    File “/usr/bin/youtube-dl/”, line 405, in _real_extract
    File “/usr/bin/youtube-dl/”, line 405, in
    KeyError: ‘sig’

    Any ideas?

  14. chrisd says:

    When you say “To pause or cancel the download, use Control-C.”, do you mean Press Ctrl + c while a terminal emulator (like Konsole) is open?

Leave a Reply

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