Download YouTube Videos in Linux Command Line
Abstract: //youtu.be/McuF7g14hYw -o audio.mp3sudo chmod a+rx /usr/local/bin/youtube-dl
Generally, we download videos from YouTube using the web browser. But now you can also download videos from YouTube using the command line.
The youtube-dl is an command line utility is developed by the the youtube-dl.org team. It is build on Python programming language, which is also required this script.
This tutorial will help you to install youtube-dl on your Linux system. Also provides you multiple useful examples for downloading audio and videos directly from Youtube.
Installing Youtube-DLUse the following command to install a YouTube command-line downloader as per your Linux operating system.
The Recommended WayTo install it right away for all UNIX users (Linux, macOS, etc.), type:
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
If you do not have curl, you can alternatively use a recent wget:
From Repositoriessudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
- Installing on Ubuntu, Debian and LinuxMint
sudo apt-get install youtube-dl
- CentOS/RHEL 7/6 and SL
sudo yum install youtube-dl
- CentOS/RHEL 8 and Fedora
sudo dnf install youtube-dl
Now use the followings set of example commands to download Youtube videos with different-2 options and formats as per your requirements.
1. Download Video – Use this command to download videos directly on your system.
youtube-dl https://www.youtube.com/watch?v=McuF7g14hYw [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: How to Download Java Archive using Command Line -McuF7g14hYw.mp4 [download] 100% of 3.79MiB in 00:09
2. Save Videos with Different Name – Use option -o followed by new video file name to save on your system disk.
youtube-dl https://www.youtube.com/watch?v=McuF7g14hYw -o Video.mp4 [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: Video.mp4 [download] 100% of 3.79MiB in 00:07
3. Download Audio in MP3 Only – You can simply download audio of any video on your system in mp3 formats, like following commands.
youtube-dl --extract-audio --audio-format mp3 https://youtu.be/McuF7g14hYw -o audio.mp3 [youtube] McuF7g14hYw: Downloading webpage [youtube] McuF7g14hYw: Downloading video info webpage [youtube] McuF7g14hYw: Extracting video information [youtube] McuF7g14hYw: Downloading DASH manifest [youtube] McuF7g14hYw: Downloading DASH manifest [download] Destination: /home/sysadmin/Desktop/audio.mp3 [download] 100% of 4.16MiB in 00:11 [ffmpeg] Correcting container in "audio.mp3" [ffmpeg] Post-process file audio.mp3 exists, skipping