Download Youtube videos using Terminal/Command Line in Linux

Download Youtube videos using Terminal/Command Line in Linux, mmm… I know, many of you has been search for a software for downloading videos from Youtube.Like Windows, Linux doesn’t have a very user friendly tool. In Windows I was using IDM (Internet Download Manager) added with the corresponding Browser extensions. I was cool, it will just pop-up a window , you can easily start downloading. However, When your browser upgrades, it collapse IDM extension most of the times.There are a lot other, but, In my words IDM most effective for Windows for downloading anything.

In case of Linux, IDM doesn’t exist.Whatever exist, it’s not effective as IDM.So, i started my searching on Google and found an incredible tool, Youtube DL.

To install it for all the UNIX users (Linux, OS X, etc.), type:

sudo curl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

In case of absence of Curl, use wget:

sudo wget -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

For Debian based distro’s like Ubuntu/Debian/Mint use:

$ sudo add-apt-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install youtube-dl

Youtube-dl (Youtube Downloader) is a simple command line tool.
You can use the command youtube-dl after installation, for downloading videos

To download a video from youtube, simply run the following command.The url can be copied from the browser itself.

# youtube-dl

Sample Output

[youtube] iRYvuS9OxdA: Downloading webpage
[youtube] iRYvuS9OxdA: Downloading video info webpage
[youtube] iRYvuS9OxdA: Extracting video information
[youtube] iRYvuS9OxdA: Downloading js player new-en_US-vflCeB3p5
[youtube] iRYvuS9OxdA: Downloading DASH manifest
[download] Destination: Amy Macdonald - This Is The Life-iRYvuS9OxdA.mp4
[download] 100% of 10.33MiB in 00:01

To find all available formats of video file, use option “–list-formats” with the youtube-dl command, with the url of the video.

# youtube-dl --list-formats

Sample Output

[youtube] qO8L1enfFOE: Downloading webpage
[youtube] qO8L1enfFOE: Downloading video info webpage
[youtube] qO8L1enfFOE: Extracting video information
[youtube] qO8L1enfFOE: Downloading DASH manifest
[youtube] qO8L1enfFOE: Downloading DASH manifest
[information] Available formats for qO8L1enfFOE
format code  extension  resolution note
249          webm       audio only DASH audio   52k , opus @ 50k, 1.20MiB
250          webm       audio only DASH audio   79k , opus @ 70k, 1.75MiB
171          webm       audio only DASH audio  114k , vorbis@128k (44100Hz), 2.53MiB
140          m4a        audio only DASH audio  128k , m4a_dash container, aac  @128k (44100Hz), 2.99MiB
251          webm       audio only DASH audio  156k , opus @160k, 3.49MiB
278          webm       256x144    DASH video  103k , webm container, vp9, 15fps, video only, 2.09MiB
160          mp4        256x144    DASH video  110k , avc1.42c00c, 15fps, video only, 2.57MiB
242          webm       426x240    DASH video  219k , vp9, 30fps, video only, 3.15MiB
133          mp4        426x240    DASH video  250k , avc1.4d4015, 30fps, video only, 5.75MiB
243          webm       640x360    DASH video  400k , vp9, 30fps, video only, 5.48MiB
134          mp4        640x360    DASH video  431k , avc1.4d401e, 30fps, video only, 5.74MiB
244          webm       854x480    DASH video  727k , vp9, 30fps, video only, 8.93MiB
135          mp4        854x480    DASH video  797k , avc1.4d401f, 30fps, video only, 11.76MiB
247          webm       1280x720   DASH video 1349k , vp9, 30fps, video only, 17.38MiB
136          mp4        1280x720   DASH video 1447k , avc1.4d401f, 30fps, video only, 23.02MiB
248          webm       1920x1080  DASH video 2303k , vp9, 30fps, video only, 34.00MiB
137          mp4        1920x1080  DASH video 2582k , avc1.640028, 30fps, video only, 42.94MiB
17           3gp        176x144    small ,  mp4a.40.2, mp4v.20.3
36           3gp        320x240    small ,  mp4a.40.2, mp4v.20.3
5            flv        400x240    small 
43           webm       640x360    medium ,  vorbis, vp8.0
18           mp4        640x360    medium ,  mp4a.40.2, avc1.42001E
22           mp4        1280x720   hd720 ,  mp4a.40.2, avc1.64001F (best)

Download a video with corresponding format, use the option ‘-f’ (format code).For example:

# youtube-dl -f 18

To download the video files list, use the following command:

# youtube-dl -a youtube_links.txt

To find more options and help use:

# youtube-dl --help

If you stop a download from a command line or closes the terminal accidentally, don’t worry.Just type it again, and the download will resume instantly.
Github repository path for youtube-dl: Youtube DL
Want to download all commands as a text file click here :Youtube DL Commands
[wpdm_package id=’115′]

So, that’s it. Concluded. I Hope you like this article Download Youtube videos using Terminal/Command Line in Linux. Drop your comments and doubts below.