sandra_henrystocker
Unix Dweeb

How to download and play YouTube and other videos on Linux

How-To
Oct 13, 20203 mins

The youtube-dl tool makes it very easy to download both webm and mp4 files on Linux systems. You just need the tool and the right URLs.

A user video conferences via tablet. [teleconference / online meeting / digital event]
Credit: Alvarez / Getty Images

Who would have imagined that there’s a Linux tool available for downloading YouTube videos? Well, there is and it works for Linux as well as for other operating systems. So, if you need to watch some of the available videos even when your internet connection is flaky or you need to be offline for a while, this tool can be especially handy.

The tool for downloading videos is called youtube-dl. (The “dl” portion undoubtedly means “download”.) It’s very easy to use and drops webm or mp4 files onto your system. Both formats provide compressed, high-quality video files that you can watch whenever you like.

The youtube-dl tool is a Python-based command-line tool. On Linux, it requires Python (2.6, 2.7, or 3.2+). The command to install it on Ubuntu and related systems is:

$ sudo apt-get install youtube-dl

Once installed, you can use a command like this to download a video after selecting the URL from YouTube or some other source:

$ youtube-dl 
sandra_henrystocker

Sandra Henry-Stocker was a programmer, Linux systems administrator, security engineer and Linux journalist for most of her 30-year career. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders. Tune into her 2-Minute Linux video tutorials and take command of your command line.

More from this author