{"id":14814,"date":"2024-10-09T09:53:36","date_gmt":"2024-10-09T09:53:36","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=14814"},"modified":"2024-10-09T12:11:19","modified_gmt":"2024-10-09T12:11:19","password":"","slug":"wget-command-examples-to-download-files-in-linux","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/","title":{"rendered":"Wget Command Examples to Download Files in Linux"},"content":{"rendered":"\n<p>Wget is a powerful, non-interactive command-line utility used to download files from the web in Linux and other Unix-based systems. It supports downloading via HTTP, HTTPS, and FTP protocols, making it a versatile tool for transferring files. Whether you&#8217;re downloading a single file, entire directories, or even websites, <code>wget<\/code> has plenty of useful features.<\/p>\n\n\n\n<p>Below are some practical examples of <code>wget<\/code> commands to download files in Linux.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Linux-based operating system<\/strong>: Ensure that you&#8217;re using a Linux distribution (such as Ubuntu, CentOS, or Debian).<\/li>\n\n\n\n<li><strong>Wget installed<\/strong>: <code>Wget<\/code> is often pre-installed on many Linux systems. To verify or install it, run:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo apt install wget # For Debian\/Ubuntu systems\nsudo yum install wget # For CentOS\/RHEL systems\nsudo dnf install wget # For Fedora systems<\/strong><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Wget Command Examples<\/strong><\/h3>\n\n\n\n<p>In all the examples given below, remember to replace the URLs with your actual URLs where you are downloading the files from.<\/p>\n\n\n\n<p>Also, the file being downloaded shoud have correct permissions (like 644) that allow it to be downloaded<\/p>\n\n\n\n<p>1. <strong>Download a Single File to the current directory<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can run the command below to download one file to the current working directory.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget https:\/\/truehost.com\/download.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>2. Download a File and Save it at a Specific Location<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you want to download the file at any location other than the current working directory.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -P \/path\/to\/directory https:\/\/truehost.com\/yourfile.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>3. Download a File and Rename It<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To download a file and save it with a different name, use the <code>-<\/code>O option (<strong>capital &#8220;O&#8221;<\/strong>) placed before the URL:<\/li>\n\n\n\n<li>The below command saves <code><strong>file<\/strong>.<strong>txt<\/strong><\/code> as <code><strong>new_name<\/strong>.<strong>txt<\/strong><\/code>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -O new_name.txt http:\/\/truehost.com\/file.txt<\/strong><\/code><\/pre>\n\n\n\n<p><strong>4. Resume Interrupted Downloads<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If a download is interrupted, you can resume it by using the <code>-c<\/code> option.<\/li>\n\n\n\n<li>This command resumes the download from where it left off, rather than starting from scratch.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -c http:\/\/truehost.com\/yourfile.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>5. Download Multiple Files<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can download multiple files by specifying URLs in a text file and using the <code>-i<\/code> option:<\/li>\n\n\n\n<li>In the command below <code>file_list.txt<\/code> contains the URLs of the files to be downloaded, with each URL on a new line.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -i file_list.txt<\/strong><\/code><\/pre>\n\n\n\n<p><strong>6. Download a Website (Mirror)<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can download an entire website recursively (mirroring) using the -r option.<\/li>\n\n\n\n<li>This command downloads all files from the website and preserves the directory structure.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -r http:\/\/example.com\/<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To ensure that all files are saved for offline viewing (with relative links), you can use:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -r -k http:\/\/example.com\/<\/strong><\/code><\/pre>\n\n\n\n<p><strong>7. Limit Download Speed<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you have bandwidth limitations or want to control the download speed, use the &#8211;limit-rate option.<\/li>\n\n\n\n<li>This limits the download speed to 200KB\/s.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --limit-rate=200k http:\/\/truehost.com\/yourFile.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>8. Download Files in Background<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To download a file in the background, use the <code>-b<\/code> option:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget -b http:\/\/<strong>truehost<\/strong>.com\/<strong>yourFile<\/strong>.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>9. Download Files with Authentication<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To download a file from a password-protected URL, use the &#8211;user and &#8211;password options.<\/li>\n\n\n\n<li>Replace <code>username<\/code> and <code>password<\/code> with the actual credentials.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --user=username --password=password http:\/\/example.com\/<strong>yourFile<\/strong>.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>10. Download Files with Cookies<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Some websites require cookies for downloads. You can pass cookies to wget using the &#8211;load-cookies option.<\/li>\n\n\n\n<li>First, save the cookies to <code>cookies.txt<\/code> and then use it with this command.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --load-cookies cookies.txt http:\/\/<strong>truehost<\/strong>.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>11. Download Using FTP<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can download files from an FTP server using wget:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget ftp:\/\/ftp.<strong>truehost<\/strong>.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the FTP server requires authentication:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --ftp-user=username --ftp-password=password ftp:\/\/ftp.<strong>truehost<\/strong>.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>12. Set a Number of Retries for Failed Downloads<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>By default, <code>wget<\/code> retries failed downloads a limited number of times. To set a custom retry limit, use the <code>--tries<\/code> option:<\/li>\n\n\n\n<li>This command will retry up to 10 times if the download fails.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --tries=10 http:\/\/truehost.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>13. Check File Size Before Downloading<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you want to check the file size before downloading it, use the <code>--spider<\/code> option:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --spider http:\/\/example.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<p><strong>14. Download Over an Untrusted SSL Connection<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the SSL certificate of a website is invalid or untrusted, you can bypass the SSL certificate check with.<\/li>\n\n\n\n<li><strong>Note<\/strong>: Use this option cautiously, as it can expose you to security risks.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>wget --no-check-certificate https:\/\/example.com\/file.zip<\/strong><\/code><\/pre>\n\n\n\n<p>These examples are just a few of the many possibilities with <code>wget<\/code>. For more details on its usage, you can always refer to the manual by typing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>man wget<\/strong><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Wget is a powerful, non-interactive command-line utility used to download files from the web in Linux and other Unix-based systems. It supports downloading via HTTP, HTTPS, and FTP protocols, making it a versatile tool for transferring files. Whether you&#8217;re downloading a single file, entire directories, or even websites, wget has plenty of useful features. Below [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-14814","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":740,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Wget Command Examples to Download Files in Linux -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Wget Command Examples to Download Files in Linux -\" \/>\n<meta property=\"og:description\" content=\"Wget is a powerful, non-interactive command-line utility used to download files from the web in Linux and other Unix-based systems. It supports downloading via HTTP, HTTPS, and FTP protocols, making it a versatile tool for transferring files. Whether you&#8217;re downloading a single file, entire directories, or even websites, wget has plenty of useful features. Below [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-09T12:11:19+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/wget-command-examples-to-download-files-in-linux\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/wget-command-examples-to-download-files-in-linux\\\/\",\"name\":\"Wget Command Examples to Download Files in Linux -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-10-09T09:53:36+00:00\",\"dateModified\":\"2024-10-09T12:11:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/wget-command-examples-to-download-files-in-linux\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/wget-command-examples-to-download-files-in-linux\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/wget-command-examples-to-download-files-in-linux\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Wget Command Examples to Download Files in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Wget Command Examples to Download Files in Linux -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"Wget Command Examples to Download Files in Linux -","og_description":"Wget is a powerful, non-interactive command-line utility used to download files from the web in Linux and other Unix-based systems. It supports downloading via HTTP, HTTPS, and FTP protocols, making it a versatile tool for transferring files. Whether you&#8217;re downloading a single file, entire directories, or even websites, wget has plenty of useful features. Below [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/","article_modified_time":"2024-10-09T12:11:19+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/","name":"Wget Command Examples to Download Files in Linux -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-10-09T09:53:36+00:00","dateModified":"2024-10-09T12:11:19+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/wget-command-examples-to-download-files-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"Wget Command Examples to Download Files in Linux"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=14814"}],"version-history":[{"count":11,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14814\/revisions"}],"predecessor-version":[{"id":14832,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14814\/revisions\/14832"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=14814"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=14814"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=14814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}