The wget Command | How to Download Files From a Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome back to lenode in today's video what we're going to do is check out the W get command and wget is very cool because what it allows us to do is fetch files from the internet without even having to open up a web browser and considering that most linode instances won't even have a GUI because you don't need a GUI on a Linux server unless you want a GUI but we're not going to require a GUI just to download files wget more than has us covered when it comes to that so let's go ahead and get started with today's video and I'll show you some examples of wget in action so let's get started thank you so the first thing that we should do is make sure that wget is actually installed and to do that we'll type which and then W get just like this and if you see output like this that means that wget is actually installed on my end I'm actually running on Fedora so if I didn't have wget installed then what I could do is run sudo dnf install and then W get just like that or if I'm using a different package manager then what I could do is use that package manager and regardless of your distro the package should be named as wget like you see right here so go ahead and install that with your package manager if you don't already have wget on your system anyway wget is installed and it's ready to go so let's see some examples one very popular use case for wget is to download an archive that contains an application that we want to install granted not every application that you might want to run on your server is downloadable via W git but it is a very popular use case when you want to deploy an application on your server the process usually starts by downloading the application that we intend on installing now not every application that you might want to run on your server is downloadable this way but many of them are so what I'm going to do is show you the process of downloading WordPress WordPress is a super popular platform for blogging and Publishing web content but we're not actually going to be setting up a WordPress server in this particular video but perhaps that's something that I might cover in the future so the first thing that we'll need is the URL I don't know about you but on my end I don't personally have the download URL for WordPress memorized so what we'll need to do is open up a browser and then what we'll do is go to wordpress.org and then we have a button right here that says get WordPress so I'll click on that and as an aside this website can change at any time and wget isn't specific to Wordpress it's just an example so it shouldn't really matter anyway after I clicked on the get WordPress button it brought me right here to the download page so what I'll do is scroll down and right here we have the download link but instead of left clicking on this like I would normally do what I'm going to do instead is right click on it and then I'm going to click right here where it says copy link now depending on your browser the verbiage here might be different but it should be more or less the same so click on that right here and let's go back to the terminal and what we'll do is type w get and then right here I'll paste in the URL and there it is so if this works what should happen is wget should actually fetch the zip file that's at this URL right here which just so happens to be the installation files that are required for a WordPress installation so I'll press enter and wow look at that it downloaded very quickly we have the download file right here and to prove that you can see that we have the latest.zip file and if the name is any indication that's the latest version of WordPress but anyway we were able to use wget to download something from the internet and that completes our first example so now we know the basic usage of wget we were able to use it to download WordPress the installation files for WordPress that are in this ZIP file and that's the end of the first example now just like most commands when it comes to Linux there's other options that we could use a w get to customize it or actually tweak the behavior of wget so let's see some additional examples and the first one is going to be the dash capital L option so if I recall the previous command which is right here what I could do is add the dash capital O option right here and what this allows me to do is actually change the name of the downloaded file so if I wanted to call it wp.zip for example I could certainly do that because the dash o option allows us to set a custom name for the file so I'll press enter foreign both of the files right here and they are the exact same size we can see the file size right here for the first one that we've downloaded and then you'll notice for wp.zip it's the same file size because well they are the same file so as you can see when we use the dash capital O option that allows us to set the name so I was able to override the name the default name of latest.zip at the server side and then name it wp.zip here on the local server now to be fair I could just accept the default name when I go to use wget and then rename it later but that is legitimately another step so while I could simply rename the file manually it might make sense for you especially if you're scripting this to have the name as something specific all in one command rather than waste a line in a script file or something like that we could set the name like you see here so for the next example what I'm going to do is show you how you can actually choose the location for the downloaded file as well by default wget will download whatever it is you're downloading to your current working directory but if you want to redirect that file somewhere else you can absolutely do that and that's exactly what I'll show you right now so in order to set a custom path for the downloaded file what we'll do is we'll use the dash capital P option like you see right here and then right after that we'll give it a custom path I'll just save mine in my downloads directory here but on your server you might have a download directory somewhere else just go ahead and update your path accordingly if you're following along with me but we have the dash capital P option we have a path and then we need to tell wget what in particular we want to download which again is going to be WordPress because well why not use that as an example again I already have the URL so it's easy to do and that was at wordpress.org and then latest dot zip install press enter and then we'll list the storage and as you can see right there in my downloads directory we have the latest.zip file that we grabbed from the WordPress server and it's ready to go right there in my downloads directory now so far the WordPress example the latest.zip file that's a very small file and it downloads extremely quickly but what if you're downloading something that's quite large and for some reason you lose network connection if you have a slower connection that might be a little painful to start all over again especially if the file is extremely large so what I'm going to do right now is actually use a different file as an example and this is actually another reason why wget is often used we'll sometimes use it to download ISO files for Linux distributions off camera I went ahead and grabbed the URL for the ISO file for Alma Linux from one of the mirrors and the official website so I'll paste that right here now this file is going to be on the larger side so it's going to take a bit of time for this to download now my internet connection is actually reasonably fast so it might not take all that long but it's definitely going to take longer than that WordPress file so what I'll do is open up a new tab and then in the original tab I'll start the download and then once the download starts I'll close the tab to simulate an interrupted download and then we'll see how we can go ahead and resume the download so as you can see it's downloading right now this is the official ISO file for all my Linux and as an aside I have a video that I've uploaded recently that shows you the installation process for Alma Linux so definitely check that one out if you're interested but anyway back to wget I have the download going right here and let's go ahead and cancel it I'm just going to close this tab and it's gone so the download was interrupted and I would rather not start over so what can we do well here's the command right here that we use to at least attempt to download earlier so what I'm going to do is add the dash C option and if this is actually successful then what that should allow us to do is resume the download right where we left off and I didn't even try this ahead of time off camera or anything like that so I don't even know if the alma Linux ISO file if that web server that's serving this file actually supports the ability to resume so I'm going to find out along with you guys whether or not this works anyway I'll press enter let's see and it looks like it's working wow so I was able to continue the download without starting from scratch and that's awesome now I already have all my Linux downloaded so I'm not going to wait for this to finish I'm going to cancel it this time and I won't resume it we see that it was actually working so I think that's good enough for now and then we can move on to the next example so next what I'll show you how to do is actually use an input file with wget so for example I'll use Nano you can use whatever text editor you would like and what we'll do is we'll create a text file I just call my fetch list Dot txt and I'll paste the iso download link right here as the first item in this file so there we have the ISO file the download link for the ISO file that I grabbed from the alma Linux website and in addition to that I'll add another URL right here let's add wordpress.org latest dot zip and then I'll add another one as well and actually we should have the S right there for that one and I have two URLs right there that I want to grab basically the two files that we've been working with so far so I'll save the file and exit out and we have the fetch list right there so what I'm going to do is type w get and then Dash I for input file and I'll give it the text file that we've just created and if this works what it should do is actually download everything that was contained inside that file and so far it's actually downloading the Centos ISO file as you can see right here so I won't cancel it this time because I actually do want to see this continue I want to see it continue and download the WordPress file as well which should be downloaded right after this one right here is finished and that'll confirm that our fetch list is actually working and check that out it actually downloaded the WordPress installation file right after it finished with the Alma Linux file since we had two URLs in the text file that I used for this example that makes sense so now as you can see you can actually Define URLs right in a text file and then you can point that text file right to wget and wget will take care of downloading those files right to your server as you just saw wget is awesome there's just something about being able to download files from the internet without a browser that's just so cool now granted we did use a browser to grab the download URL which we will need in order to know what to download but beyond that wget doesn't really need a browser we just simply plug in a URL and then we download a file so hopefully the examples that I gave you guys in today's video helped you with learning the W get command and sure it's one of these simpler commands that you can learn but it's very effective if this video has helped you out please click that like button and once you've done that also click that subscribe button because there's additional videos that I'm creating for lenode and actually as soon as I'm done with this particular video I'm going to record the next so you'll definitely want to see that next video as soon as it's uploaded anyway thank you guys so much for checking out this video I really appreciate it and I'll see you again very soon foreign [Music]
Info
Channel: Akamai Developer
Views: 13,210
Rating: undefined out of 5
Keywords: linode, linux, cloud computing, alternative cloud, linux server, open source, sysadmin, wget, linux wget, linux downlaod, linux commands, command line, command line basics, basic linux commands, wget and curl, linux curl, linux wget command, linux curl command, what is wget, wget in linux, how wget works, linux wget command line, linode wget, linode wget command, linux basic commands, linux for beginners, linux commands overview, wget overview, wget linux command line
Id: zszbBJ81_YU
Channel Id: undefined
Length: 12min 39sec (759 seconds)
Published: Wed Oct 26 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.