{"id":88,"date":"2012-07-23T20:29:00","date_gmt":"2012-07-23T20:29:00","guid":{"rendered":"https:\/\/www.tech-and-dev.com\/blog\/2012\/07\/23\/working-with-wget-command-to-download-a-single-file-or-to-download-files-from-a-ftp-with-a-username-and-password\/"},"modified":"2012-07-23T20:29:00","modified_gmt":"2012-07-23T20:29:00","slug":"working-with-wget-command-to-download","status":"publish","type":"post","link":"https:\/\/www.tech-and-dev.com\/blog\/2012\/07\/working-with-wget-command-to-download.html","title":{"rendered":"Working with Wget command to download a single file or to download files from a ftp with a username and password"},"content":{"rendered":"<p>Wget stands for <b>World Wide Web<\/b> and <b>get<\/b>.<\/p>\n<p>Usually Wget is used to download a file from a http server (or https), and even ftp servers.<br \/>Wget can also be used to download an entire directory recursively.<\/p>\n<p>In this post, I will show you 5 ways for using wget <\/p>\n<h3> 1- Using Wget to download a single file<\/h3>\n<p>To download a single file, simply write wget followed by the url, for this example, I will download a test file from thinkbroadband.com<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">wget http:\/\/download.thinkbroadband.com\/100MB.zip<\/div>\n<p>Below, you will see the file being downloaded<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">Saving to: &#8216;100MB.zip&#8217;<\/p>\n<p>34% [============&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ] 36,639,898&nbsp; 5.90M\/s&nbsp; eta 13s<\/p><\/div>\n<p><b>Saving to: 100MB.zip<\/b> : This is the filename that is being saved on your server\/computer<br \/><b>34%<\/b>:&nbsp; Percentage of the completion of the file being downloaded<br \/><b>36,639,898<\/b> : Number of bytes downloaded so far<br \/><b>5.90M\/s<\/b> : Current download speed<br \/><b>eta 13s<\/b> : The remaining estimation time left to complete the download<\/p>\n<p>Once the download is completed, you will see something that look like this:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">Saving to: &#8216;100MB.zip&#8217;<\/p>\n<p>100%[======================================&gt;] 104,857,600 4.17M\/s&nbsp;&nbsp; in 23s<\/p>\n<p>2012-07-23 23:29:16 (4.33 MB\/s) &#8211; &#8216;100MB.zip &#8216;<\/p><\/div>\n<p>In the last line, you will see:<br \/><b>2012-07-23 23:29:16<\/b> : the date the file was completely downloaded<br \/><b>(4.33 MB\/s) <\/b>: Average download speed for the entire download<br \/><b>100MB.zip <\/b>: the filename of the downloaded file<\/p>\n<p><\/p>\n<h3> 2- Using Wget to resume a single file (-c option)<\/h3>\n<p>If you were downloading a file, and the download was interrupted whether you had to restart your computer, or internet disconnected or any other reason, you can use wget command with -c option to resume it:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">wget -c http:\/\/download.thinkbroadband.com\/512MB.zip<\/div>\n<p><\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">Saving to: &#8216;512MB.zip&#8217;<\/p>\n<p>100%[++++++================================&gt;] 536,870,912 8.99M\/s&nbsp;&nbsp; in 54s<\/p>\n<p>2012-07-23 23:42:16 (8.04 MB\/s) &#8211; &#8216;512MB.zip&#8217;<\/p><\/div>\n<p>Notice the ++++ in the download bar, this means that this portion of the file was already downloaded, the ======= is the new portion being downloaded.<\/p>\n<h3> 3- Using Wget to download in the background (-b option)<\/h3>\n<p>If you want to download a file while doing other stuff in the command line, you can use the -b option, for example:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">wget -b http:\/\/download.thinkbroadband.com\/512MB.zip<br \/>Continuing in background, pid 26530.<br \/>Output will be written to &#8216;wget-log&#8217;<\/div>\n<p>This will start the download in the background while giving back the shell command to you to allow you to write other commands.<\/p>\n<p>To check the status of the download, simply enter the following command:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">tail -f wget-log<\/div>\n<p>and you will see the download status, for example:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">509450K &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. 97% 25.2M 3s<br \/>509500K &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. 97% 10.8M 3s<br \/>509550K &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. 97% 6.25M 2s<br \/>509600K &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. 97% 22.4M 2s<br \/>509650K &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. &#8230;&#8230;&#8230;. 97% 11.5M 2s<\/div>\n<p><\/p>\n<h3> 4- Using Wget to download from a FTP<\/h3>\n<p>For this example, I will download a file from the mozilla ft:p<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">wget ftp:\/\/ftp.mozilla.org\/index.html<\/div>\n<p><\/p>\n<h3> 5- Using Wget to recursively download a directory from a FTP with a username and password<\/h3>\n<p>To recursively download all the files from a ftp with a username and password, use the following wget command:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">wget -r ftp:\/\/test:test@ftp.secureftp-test.com:21\/subdir1\/*<\/div>\n<p><b>username <\/b>= test<br \/><b>password <\/b>= test<br \/><b>host <\/b>= ftp.secureftp-test.com<br \/><b>port<\/b>=21<br \/><b>directory to download<\/b> = subdir1<\/p>\n<h3> &nbsp;<\/h3>\n<h3> Installing Wget (on CentOS 6.2)<\/h3>\n<p>If you get the following message while using wget:<\/p>\n<div style=\"background-color: black; color: white; padding: 5px;\">-bash: wget: command not found<\/div>\n<p>This means that your Wget is not installed.<\/p>\n<p>To install wget, run the below command:<\/p>\n<div style=\"background-color: #eeeeee; padding: 5px;\">[root@myserver ~]# yum install wget<br \/>Loaded plugins: fastestmirror<br \/>Loading mirror speeds from cached hostfile<br \/>&nbsp;* base: mirror.beyondhosting.net<br \/>&nbsp;* extras: centos.corenetworks.net<br \/>&nbsp;* updates: mirrors.serveraxis.net<br \/>Setting up Install Process<br \/>Resolving Dependencies<br \/>&#8211;&gt; Running transaction check<br \/>&#8212;&gt; Package wget.x86_64 0:1.12-1.4.el6 will be installed<br \/>&#8211;&gt; Finished Dependency Resolution<\/p>\n<p>Dependencies Resolved<\/p>\n<p>================================================================================<br \/>&nbsp;Package&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Arch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Repository&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size<br \/>================================================================================<br \/>Installing:<br \/>&nbsp;wget&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x86_64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.12-1.4.el6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; base&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 481 k<\/p>\n<p>Transaction Summary<br \/>================================================================================<br \/>Install&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 Package(s)<\/p>\n<p>Total download size: 481 k<br \/>Installed size: 1.8 M<br \/>Is this ok [y\/N]: y<br \/>Downloading Packages:<br \/>wget-1.12-1.4.el6.x86_64.rpm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | 481 kB&nbsp;&nbsp;&nbsp;&nbsp; 00:00<br \/>Running rpm_check_debug<br \/>Running Transaction Test<br \/>Transaction Test Succeeded<br \/>Running Transaction<br \/>&nbsp; Installing : wget-1.12-1.4.el6.x86_64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/1<\/p>\n<p>Installed:<br \/>&nbsp; wget.x86_64 0:1.12-1.4.el6<\/p>\n<p>Complete!<\/p><\/div>\n<p>Happy WGETting \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wget stands for World Wide Web and get. Usually Wget is used to download a file from a http server (or https), and even ftp servers.Wget can also be used to download an entire directory recursively. In this post, I will show you 5 ways for using wget 1- Using Wget to download a single [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[123,6,122,7],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-download","category-linux","category-recursive","category-ssh"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":0,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-and-dev.com\/blog\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}