While many websites offer tools to download YouTube videos, they are frequently filled with pop-up ads, malware risks, or strict resolution limits. For Linux users, the most powerful, ad-free, and reliable way to download videos for offline viewing is using a command-line utility called yt-dlp.
yt-dlp is a modern, actively maintained fork of the classic youtube-dl project. It regularly bypasses YouTube’s throttling mechanisms, supports thousands of other video hosting sites, and allows you to download videos in full 4K resolution.
Step 1: Install yt-dlp
While yt-dlp is available in some package managers, the versions in default repositories are often hopelessly outdated, causing downloads to fail when YouTube updates its code. The best method is to install the latest binary directly from GitHub.
Open your terminal and run the following commands to download it and make it executable:
sudo wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlp
Note: If you do not have wget installed, you can use curl -L instead.
Step 2: Basic Video Downloading
The simplest way to use the tool is to provide it with a video URL. It will automatically download the highest possible quality video and audio format and merge them.
yt-dlp "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"
Always wrap the URL in quotation marks to prevent the terminal from misinterpreting special characters (like & or ?) present in the web address.
Step 3: Downloading Audio Only (MP3)
If you only want to listen to a podcast, lecture, or song, downloading the video track is a waste of bandwidth and storage space. You can instruct yt-dlp to extract only the audio and convert it to a standard MP3 file.
yt-dlp -x --audio-format mp3 "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"
Understanding the flags:
-x: Tells the program to extract audio only.--audio-format mp3: Forces the program to convert the downloaded audio stream into a universally playable MP3 file.
Important: This conversion step requires ffmpeg to be installed on your system. If you receive an error, simply install it using your package manager (e.g., sudo apt install ffmpeg).
Step 4: Downloading Entire Playlists
One of the most powerful features of this tool is its ability to download entire playlists with a single command. Simply provide the URL of the playlist page instead of an individual video.
yt-dlp "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"
The tool will automatically create a queue, downloading every video sequentially into your current working directory.