{"id":44958,"date":"2022-04-19T10:59:58","date_gmt":"2022-04-19T10:59:58","guid":{"rendered":"https:\/\/linuxiac.com\/?p=44958"},"modified":"2022-04-19T11:00:13","modified_gmt":"2022-04-19T11:00:13","slug":"wget-command-examples","status":"publish","type":"post","link":"https:\/\/linuxiac.com\/wget-command-examples\/","title":{"rendered":"Top 10 Use Cases of Wget Command (with Examples)"},"content":{"rendered":"\n<p>Wget is a command-line utility for downloading files from the web, created by the <a href=\"https:\/\/www.gnu.org\/software\/wget\/\" target=\"_blank\" rel=\"noreferrer noopener\">GNU Project<\/a>. The name is a combination of &#8220;World Wide Web&#8221; and &#8220;get.&#8221;<\/p>\n\n\n\n<p>Wget allows you to download files using HTTP, HTTPS, and FTP protocols. In addition, it gives you the ability to download multiple files, resume downloads, limit bandwidth, perform recursive downloads, download in the background, mirror a website, and even more.<\/p>\n\n\n\n<p>By the end of this guide, you&#8217;ll know everything there is to know about the <code>wget<\/code> command and how to use it to download files from the Internet.<\/p>\n\n\n\n<div class=\"wp-block-ultimate-post-table-of-content ultp-block-df342f\"><div class=\"ultp-block-wrapper\"><div class=\"ultp-block-toc\"><div class=\"ultp-toc-header\"><div class=\"ultp-toc-heading\">Table of Contents<\/div><div class=\"ultp-collapsible-toggle  ultp-collapsible-right\"><a class=\"ultp-collapsible-text ultp-collapsible-open\" href=\"javascript:;\">[Open]<\/a><a class=\"ultp-collapsible-text ultp-collapsible-hide\" href=\"javascript:;\">[Close]<\/a><\/div><\/div><div class=\"ultp-block-toc-style1 ultp-block-toc-body\" style=\"display:block;\"><ul class=\"ultp-toc-lists\"><li><a href=\"#Installing_Wget\">Installing Wget<\/a><ul class=\"ultp-toc-lists\"><li><a href=\"#Installing_Wget_on_Ubuntu,_Debian,_and_Other_Debian-based_Distros\">Installing Wget on Ubuntu, Debian, and Other Debian-based Distros<\/a><\/li><li><a href=\"#Installing_Wget_on_Fedora,_RHEL,_and_Other_RHEL-based_Distros\">Installing Wget on Fedora, RHEL, and Other RHEL-based Distros<\/a><\/li><li><a href=\"#Installing_Wget_on_Manjaro,_Arch_Linux,_and_Other_Arch_Linux-based_Distros\">Installing Wget on Manjaro, Arch Linux, and Other Arch Linux-based Distros<\/a><\/li><\/ul><\/li><li><a href=\"#Wget_Command_Syntax\">Wget Command Syntax<\/a><\/li><li><a href=\"#_Download_a_File_Using_Wget\">1. Download a File Using Wget<\/a><\/li><li><a href=\"#_Using_Wget_Command_to_Rename_Downloaded_File\">2. Using Wget Command to Rename Downloaded File<\/a><\/li><li><a href=\"#_Download_Multiple_Files_Using_Wget\">3. Download Multiple Files Using Wget<\/a><\/li><li><a href=\"#_Resume_a_Download_Using_Wget\">4. Resume a Download Using Wget<\/a><\/li><li><a href=\"#_Download_Files_in_Background_Using_Wget\">5. Download Files in Background Using Wget<\/a><\/li><li><a href=\"#_Limit_the_Download_Speed_Using_Wget\">6. Limit the Download Speed Using Wget<\/a><\/li><li><a href=\"#_Download_a_File_to_a_Specific_Directory\">7. Download a File to a Specific Directory<\/a><\/li><li><a href=\"#_Download_Password_Protected_Files_via_HTTP_or_FTP_Using_Wget\">8. Download Password Protected Files via HTTP or FTP Using Wget<\/a><\/li><li><a href=\"#_Skipping_Certificate_Check\">9. Skipping Certificate Check<\/a><\/li><li><a href=\"#_Download_a_Website_Content_Using_Wget\">10. Download a Website Content Using Wget<\/a><\/li><li><a href=\"#Conclusion\">Conclusion<\/a><\/li><\/ul><\/div><\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Installing_Wget\">Installing Wget<\/h2>\n\n\n\n<p>The wget package comes pre-installed on most Linux distros. However, if the <code>wget<\/code> command is not installed on your system, you can easily install it using the package manager.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"Installing_Wget_on_Ubuntu,_Debian,_and_Other_Debian-based_Distros\">Installing Wget on Ubuntu, Debian, and Other Debian-based Distros<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo apt install wget<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"Installing_Wget_on_Fedora,_RHEL,_and_Other_RHEL-based_Distros\">Installing Wget on Fedora, RHEL, and Other RHEL-based Distros<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo dnf install wget<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"Installing_Wget_on_Manjaro,_Arch_Linux,_and_Other_Arch_Linux-based_Distros\">Installing Wget on Manjaro, Arch Linux, and Other Arch Linux-based Distros<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code lang=\"bash\" class=\"hljs language-bash\">sudo pacman -S wget<\/code><\/span><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You&#8217;ll be able to use the <code>wget<\/code> command once the setup is complete. But, first, I\u2019ll show you the ten most used <code>wget<\/code> command examples that you can use in your everyday work to get you started.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Wget_Command_Syntax\">Wget Command Syntax<\/h2>\n\n\n\n<p>The&nbsp;<code>wget<\/code>&nbsp;command expressions take the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code lang=\"bash\" class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">wget<\/span> <span class=\"hljs-selector-attr\">&#91;OPTIONS]<\/span> <span class=\"hljs-selector-attr\">&#91;URL]<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>[OPTIONS]<\/code> tells what to do with the&nbsp;<code>[URL]<\/code>&nbsp;argument provided after.<\/li>\n\n\n\n<li><code>[URL]<\/code>&nbsp;is the file or the directory you want to download.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_a_File_Using_Wget\">1. Download a File Using Wget<\/h2>\n\n\n\n<p>The simplest way to use <code>wget<\/code> is to provide it with the location of a file to download. Then, when no options are specified, <code>wget<\/code> downloads the resource specified in the <code>[URL]<\/code> to the current directory.<\/p>\n\n\n\n<p>For example, you can get the Arch Linux installation ISO image file by doing the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file.png\"><img decoding=\"async\" width=\"1024\" height=\"292\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file-1024x292.png\" alt=\"How to download a file with wget\" class=\"wp-image-44970\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file-1024x292.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file-380x108.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file-768x219.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-single-file.png 1261w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>As a result, a file named <code>archlinux-2022.04.05-x86_64.iso<\/code> downloads in the current working directory. In addition, you&#8217;ll also see information such as the download progress, speed, size, time, and date.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Using_Wget_Command_to_Rename_Downloaded_File\">2. Using Wget Command to Rename Downloaded File<\/h2>\n\n\n\n<p>Pass the <code>-O<\/code> option followed by the preferred name to save the downloaded file under a different name.<\/p>\n\n\n\n<p>For example, the command below will save the Arch Linux installation ISO image file as&nbsp;<code>arch-install.iso<\/code>&nbsp;instead of its original name.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget -O arch-install.iso http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file.png\"><img decoding=\"async\" width=\"1024\" height=\"322\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file-1024x322.png\" alt=\"Using the wget command to rename downloaded file\" class=\"wp-image-44973\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file-1024x322.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file-380x119.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file-768x241.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-rename-file.png 1216w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_Multiple_Files_Using_Wget\">3. Download Multiple Files Using Wget<\/h2>\n\n\n\n<p>If you want to use <code>wget<\/code> to download multiple files at once, use the <code>-i<\/code> option followed by the path to the file containing a list of the URLs to be downloaded. In addition, each URL must be placed on its line.<\/p>\n\n\n\n<p>In this example, we will retrieve the ISO installation images of Arch Linux and Debian by using <code>wget<\/code>. First, however, we\u2019ll need to create a text document and insert the download URLs into it to do so.<\/p>\n\n\n\n<p>So, first, let&#8217;s create a file with a name of our choice, for example, <code>urls.txt<\/code>, and put in it the necessary URL addresses to the files we want to download.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code lang=\"bash\" class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">vim<\/span> <span class=\"hljs-selector-tag\">urls<\/span><span class=\"hljs-selector-class\">.txt<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files.png\"><img decoding=\"async\" width=\"1024\" height=\"314\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files-1024x314.png\" alt=\"How to download multiple files using wget\" class=\"wp-image-44976\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files-1024x314.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files-380x116.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files-768x235.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiply-files.png 1031w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Next, you need to use the&nbsp;<code>-i<\/code>&nbsp;option followed by the file name to download all the files stored in our text file.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code lang=\"bash\" class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">wget<\/span> <span class=\"hljs-selector-tag\">-i<\/span> <span class=\"hljs-selector-tag\">urls<\/span><span class=\"hljs-selector-class\">.txt<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files.png\"><img decoding=\"async\" width=\"1024\" height=\"628\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files-1024x628.png\" alt=\"How to download multiple files using wget\" class=\"wp-image-44982\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files-1024x628.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files-380x233.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files-768x471.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-multiple-files.png 1338w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>That&#8217;s all. Just wait for the process to finish.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Resume_a_Download_Using_Wget\">4. Resume a Download Using Wget<\/h2>\n\n\n\n<p>If you lose your internet connection, your download may be interrupted. Indeed, this is a fairly common occurrence when downloading large files.<\/p>\n\n\n\n<p>So, instead of restarting the download from scratch, use the <code>-c<\/code> option to continue it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget -c http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download.png\"><img decoding=\"async\" width=\"1024\" height=\"288\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download-1024x288.png\" alt=\"How to resume download using wget\" class=\"wp-image-44985\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download-1024x288.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download-380x107.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download-768x216.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-resume-download.png 1271w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>However, if the remote server does not support resumed downloads, <code>wget<\/code> will restart the download and overwrite the existing file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_Files_in_Background_Using_Wget\">5. Download Files in Background Using Wget<\/h2>\n\n\n\n<p>Adding the&nbsp;<code>-b<\/code>&nbsp;option to <code>wget<\/code> will send the download in the background immediately after the download start. If no output file is specified via the <code>-o<\/code> option, the output is redirected to the <code>wget-log<\/code> file.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget -b http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background.png\"><img decoding=\"async\" width=\"1024\" height=\"342\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background-1024x342.png\" alt=\"How to download files in background with wget\" class=\"wp-image-44988\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background-1024x342.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background-380x127.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background-768x256.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-in-background.png 1273w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>In addition, you can view the actions performed in the background by <code>wget<\/code> by simply viewing the contents of the <code>wget-log<\/code> file. For example, the first ten lines of its contents are shown in the image above.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Limit_the_Download_Speed_Using_Wget\">6. Limit the Download Speed Using Wget<\/h2>\n\n\n\n<p>When downloading a large file over a slow internet connection, it is sometimes necessary to limit the download rate of the <code>wget<\/code> command to prevent it from using all of your bandwidth.<\/p>\n\n\n\n<p>The following example will download the Arch Linux installation ISO image and limit the download speed to 1MB:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget --limit-rate=<span class=\"hljs-number\">1<\/span>m http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed.png\"><img decoding=\"async\" width=\"1024\" height=\"264\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed-1024x264.png\" alt=\"How to limit the download speed when using wget\" class=\"wp-image-44991\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed-1024x264.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed-380x98.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed-768x198.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-limit-downloading-speed.png 1394w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_a_File_to_a_Specific_Directory\">7. Download a File to a Specific Directory<\/h2>\n\n\n\n<p>By default, <code>wget<\/code> downloads files under the current working directory. But, of course, <code>wget<\/code> can save the downloaded files in a predefined directory.<\/p>\n\n\n\n<p>The <code>-P<\/code> option is used to set the directory prefix to which all retrieved files will be saved.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget -P \/tmp\/ http:<span class=\"hljs-comment\">\/\/mirrors.mit.edu\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory.png\"><img decoding=\"async\" width=\"1024\" height=\"280\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory-1024x280.png\" alt=\"Download a file to a specific directory using wget\" class=\"wp-image-44994\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory-1024x280.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory-380x104.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory-768x210.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-download-to-directory.png 1316w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The above command will download the ISO file under the&nbsp;<code>\/tmp<\/code>&nbsp;directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_Password_Protected_Files_via_HTTP_or_FTP_Using_Wget\">8. Download Password Protected Files via HTTP or FTP Using Wget<\/h2>\n\n\n\n<p>If the website you want to download is password-protected, the standard <code>wget<\/code> commands will fail, displaying an access denied error while attempting to download.<\/p>\n\n\n\n<p>However, we could use the option below to include the username and password for the password-protected website alongside the <code>wget<\/code> commands used to retrieve the file.<\/p>\n\n\n\n<p>For example, to download a file from a password-protected <a href=\"https:\/\/linuxiac.com\/what-is-web-server\/\">HTTP server<\/a>,&nbsp;you&#8217;ll need to specify the username and password as in this <code>wget<\/code> example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget --http-user=username --http-password=password https:<span class=\"hljs-comment\">\/\/www.example.com\/filename.tar.gz<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Alternatively, to download a file from a password-protected <a href=\"https:\/\/linuxiac.com\/ftp-vs-ftps-vs-sftp\/\">FTP server<\/a>, the <code>wget<\/code> command is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget --ftp-user=username --ftp-password=password ftp:<span class=\"hljs-comment\">\/\/ftp.example.com\/filename.tar.gz<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"_Skipping_Certificate_Check\">9. Skipping Certificate Check<\/h2>\n\n\n\n<p>If you want to use <code>wget<\/code> to download a file from a server with an invalid <a href=\"https:\/\/linuxiac.com\/lets-encrypt-free-ssl-certificate\/\">SSL certificate<\/a>, for example, expired or not from a trusted issuer, you can use the <code>--no-check-certificate<\/code> option to force <code>wget<\/code> to ignore such errors.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget --no-check-certificate https:<span class=\"hljs-comment\">\/\/18.7.29.125\/archlinux\/iso\/2022.04.05\/archlinux-2022.04.05-x86_64.iso<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check.png\"><img decoding=\"async\" width=\"1024\" height=\"354\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check-1024x354.png\" alt=\"How to skip the ceriticate check when using wget\" class=\"wp-image-44997\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check-1024x354.png 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check-380x131.png 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check-768x266.png 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-skip-certificate-check.png 1159w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"_Download_a_Website_Content_Using_Wget\">10. Download a Website Content Using Wget<\/h2>\n\n\n\n<p>The <code>wget<\/code> command can also be used to download the entire content of a website. So you can use use the <code>-m<\/code> option to create a website mirror.<\/p>\n\n\n\n<p>This will make a complete local copy of the website by following and downloading all internal links and website resources.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code lang=\"bash\" class=\"hljs language-javascript language-bash\">wget -m -k -p -P \/tmp\/web\/ https:<span class=\"hljs-comment\">\/\/www.example.com<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>-m<\/td><td>Makes your download recursive.<\/td><\/tr><tr><td>-k<\/td><td>All links will be converted for proper offline usage.<\/td><\/tr><tr><td>-p<\/td><td>This will include all necessary files such as images, CSS, JS, etc.<\/td><\/tr><tr><td>-P<\/td><td>Ensures that all content goes to our specified <code>\/tmp\/web\/<\/code> directory.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>When the process is complete, you will be able to open the downloaded website locally and locate all of the files in the <code>\/tmp\/web\/<\/code> directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Conclusion\">Conclusion<\/h2>\n\n\n\n<p>By completing this guide, you have learned mot common uses for the <code>wget<\/code> command. You can now use it to download multiple files at once, resume partial downloads, mirror websites, and combine the <code>wget<\/code> options to meet your specific needs.<\/p>\n\n\n\n<p>In addition to this article, if you prefer to use the GUI client to download larger files that usually also have a torrent download option, we recommend our guide: &#8220;<a href=\"https:\/\/linuxiac.com\/best-torrent-clients\/\">Best Torrent Clients You Can Use on Linux Desktop<\/a>.&#8221;<\/p>\n\n\n\n<p>For more detailed information about the&nbsp;<code>wget<\/code>&nbsp;command, you can head to the command&#8217;s&nbsp;<a href=\"https:\/\/linux.die.net\/man\/1\/wget\" target=\"_blank\" rel=\"noopener\">man page<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide will show you how to use the wget command through 10 commonly used examples.<\/p>\n","protected":false},"author":10,"featured_media":44961,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4417],"tags":[4347],"class_list":["post-44958","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","category-linux-knowledge","tag-wget"],"blocksy_meta":{"post_title_panel":"","has_hero_section":"default","4a8fc4a2d91dfaab61a033388c4be9ea":"","hero_section":"type-2","hero_elements":[{"id":"custom_title","enabled":true,"heading_tag":"h1","title":"Home","__id":"usWwuvBIjXRodN1f_jBho"},{"id":"custom_description","enabled":false,"description_visibility":{"desktop":true,"tablet":true,"mobile":false},"__id":"1MV8Bwu_XGgEcFQd3xvi2"},{"id":"custom_meta","enabled":true,"meta_elements":[{"id":"author","enabled":true,"label":"By","has_author_avatar":"yes","avatar_size":50,"__id":"wnYe68x4h2Y6V5GIIAbzi"},{"id":"post_date","enabled":true,"label":"On","date_format_source":"default","date_format":"M j, Y","__id":"YgIwvapyos15aYHmqMpJN"},{"id":"updated_date","enabled":false,"label":"On","date_format_source":"default","date_format":"M j, Y","__id":"EpRxktdVrlI5yy3CSmFEK"},{"id":"categories","enabled":false,"label":"In","style":"simple","__id":"oEPaUzNs3aZQ3eP7Xr6X_"},{"id":"comments","enabled":true,"__id":"0Uj8zR12IgF8u-nv62iVY"}],"page_meta_elements":{"joined":true,"articles_count":true,"comments":true},"__id":"ULlKF_3NCUVI_YeKZFCSL","meta_divider":"circle"},{"id":"breadcrumbs","enabled":false,"__id":"tNIsBGnMLPXTeds8NO20F"}],"ba552557d134bbda7077c1a52756e772":"","hero_alignment1":"CT_CSS_SKIP_RULE","hero_margin":40,"hero_alignment2":"center","hero_vertical_alignment":"center","5d8b969a086ae669c370284adfcdb0c9":"","hero_structure":"normal","c8f587c8d29a95a14f5ff38a73eaf8eb":"","page_title_bg_type":"custom_image","custom_hero_background":{"attachment_id":44967,"url":"https:\/\/linuxiac.com\/wp-content\/uploads\/2022\/04\/wget-header-1024x237.jpg"},"page_title_image_size":"full","parallax":{"desktop":false,"tablet":false,"mobile":false},"70e59939ef411d18b00ea9573e9ccab5":"","hero_height":"250px","pageTitleFont":{"family":"Default","variation":"Default","size":{"desktop":"2.8em","tablet":"2.8em","mobile":"2.8em","__changed":[]},"line-height":"CT_CSS_SKIP_RULE","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"pageTitleFontColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageMetaFont":{"family":"Default","variation":"n6","size":"12px","line-height":"1.3","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"uppercase","text-decoration":"CT_CSS_SKIP_RULE"},"pageMetaFontColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"page_meta_button_type_font_colors":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"page_meta_button_type_background_colors":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageExcerptFont":{"family":"Default","variation":"Default","size":"CT_CSS_SKIP_RULE","line-height":"CT_CSS_SKIP_RULE","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"pageExcerptColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"breadcrumbsFont":{"family":"Default","variation":"Default","size":"CT_CSS_SKIP_RULE","line-height":"CT_CSS_SKIP_RULE","letter-spacing":"CT_CSS_SKIP_RULE","text-transform":"CT_CSS_SKIP_RULE","text-decoration":"CT_CSS_SKIP_RULE"},"breadcrumbsFontColor":{"default":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"initial":{"color":"CT_CSS_SKIP_RULEDEFAULT"},"hover":{"color":"CT_CSS_SKIP_RULEDEFAULT"}},"pageTitleOverlay":{"background_type":"color","background_pattern":"type-1","background_image":{"attachment_id":null,"x":0,"y":0},"gradient":"linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)","background_repeat":"repeat","background_size":"auto","background_attachment":"scroll","patternColor":{"default":{"color":"#e5e7ea"}},"overlayColor":{"default":{"color":"CT_CSS_SKIP_RULE"}},"backgroundColor":{"default":{"color":"CT_CSS_SKIP_RULE"}}},"pageTitleBackground":{"background_type":"color","background_pattern":"type-1","background_image":{"attachment_id":null,"x":0,"y":0},"gradient":"linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)","background_repeat":"repeat","background_size":"auto","background_attachment":"scroll","patternColor":{"default":{"color":"#e5e7ea"}},"overlayColor":{"default":{"color":"CT_CSS_SKIP_RULE"}},"backgroundColor":{"default":{"color":"var(--theme-palette-color-6)"}}},"pageTitlePadding":{"top":"50px","bottom":"50px","left":"auto","right":"auto","linked":true},"4638b1c21a47f08ee6369230e1938b9e":"","page_structure_type":"default","38cfbb7c1533548cda760249f2ce4c34":"","content_style_source":"inherit","content_style":"wide","b0a4ccef2e61e63688a2a0f8edde2eb8":"","vertical_spacing_source":"inherit","content_area_spacing":"both","background":{"background_type":"color","background_pattern":"type-1","background_image":{"attachment_id":null,"x":0,"y":0},"gradient":"linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)","background_repeat":"repeat","background_size":"auto","background_attachment":"scroll","patternColor":{"default":{"color":"#e5e7ea"}},"overlayColor":{"default":{"color":"CT_CSS_SKIP_RULE"}},"backgroundColor":{"default":{"color":"CT_CSS_SKIP_RULE"}}},"content_background":{"background_type":"color","background_pattern":"type-1","background_image":{"attachment_id":null,"x":0,"y":0},"gradient":"linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)","background_repeat":"repeat","background_size":"auto","background_attachment":"scroll","patternColor":{"default":{"color":"#e5e7ea"}},"overlayColor":{"default":{"color":"CT_CSS_SKIP_RULE"}},"backgroundColor":{"default":{"color":"var(--theme-palette-color-8)"}}},"content_boxed_shadow":{"inherit":false,"blur":18,"spread":-6,"v_offset":12,"h_offset":0,"inset":false,"enable":true,"color":{"color":"rgba(34, 56, 101, 0.04)"}},"boxed_content_spacing":{"desktop":{"top":"40px","bottom":"40px","left":"40px","right":"40px","linked":true},"tablet":{"top":"35px","bottom":"35px","left":"35px","right":"35px","linked":true},"mobile":{"top":"20px","bottom":"20px","left":"20px","right":"20px","linked":true}},"content_boxed_radius":{"top":"3px","bottom":"3px","left":"3px","right":"3px","linked":true},"07123f3b1c9bd6248a0dece87aeb10f8":"","disable_featured_image":"no","disable_post_tags":"no","disable_share_box":"no","disable_author_box":"no","disable_posts_navigation":"no","disable_subscribe_form":"no","422f887564a96111c409e5dfc94b5fd1":"","disable_related_posts":"no","disable_header":"no","disable_footer":"no","e3db0141e705f84bdb1aa0d89fe900bb":"","header_footer_scripts_panel":"","header_scripts":"","5c927b939901d39e4805e1efa2a05342":"","header_after_body_scripts":"","5ddad2cb4c68e61a6ca9f9b6a62d8a95":"","footer_scripts":"","styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/44958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/comments?post=44958"}],"version-history":[{"count":0,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/44958\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media\/44961"}],"wp:attachment":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media?parent=44958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/categories?post=44958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/tags?post=44958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}