I know you have already seen a few ways to download YouTube videos. But those tools were mostly GUI. I am going to show you how to download YouTube videos in Linux terminal using youtube-dl. By following this way you can download your videos at max speed as it can be.



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 rerun 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.


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.


Downloading videos from websites could be against their policies. It’s up to you if choose to download videos.


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


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


After fetching the file, you need to set an 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 the “-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

youtube-dl is a versatile command line tool and provides a number of functionalities. No wonder it is such a popular command line tool.


I have only shown some of the most common usages of this tool. But if you want to explore its capabilities further, please check its manual.


I hope this article helped you to download YouTube videos on Linux. If you have questions or suggestions, please drop a comment below.