I watched tutorials on Linux Bash and started using it. You can use the command wget to download from command line. Specifically, you could use. However because Oracle requires you to accept a license agreement this may not work and I am currently unable to test it. I guess you could use curl and wget , but since Oracle requires you to check of some checkmarks this will be painfull to emulate with the tools mentioned.
You would have to download the page with the license agreement and from looking at it figure out what request is needed to get to the actual download. Of course you could simply start a browser, but this might not qualify as 'from the command line'.
So you might want to look into lynx , a text based browser. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How do I download a file from the internet to my linux server with Bash [closed] Ask Question. Asked 8 years, 10 months ago. Active 5 years, 7 months ago. Linux distributions can be downloaded from the Microsoft Store like below.
We can access Microsoft Store from start menu with Microsoft Store keyword. We will write linux to the search box and search. Alternatively, if we are looking for a specific Linux.
The search results for the Linux container will be listed below. The following information also provided with the search results. In this example, we will select the Ubuntu image with the latest version. Ubuntu During the download, the download status will be shown in the header like below. We can see that the Ubuntu image is about MB and downloaded very fast. When the download is complete we can launch Ubuntu container from the Microsoft Store from the Launch button like below.
We will see the following bash shell where it is initialized for the first run. As it says it may take a few minutes to see the shell. If you have bash 2. Paste the following code directly into a bash shell you don't need to save the code into a file for executing :.
Source: Moreaki 's answer upgrading and installing packages through the cygwin command line? Taking the " just Bash and nothing else " strictly, here's one adaptation of earlier answers Chris's , 's that does not call any external utilities not even standard ones but also works with binary files:. We deal with NUL bytes with read -d ''.
It reads until a NUL byte, and returns true if it found one, false if it didn't. Bash can't handle NUL bytes in strings, so when read returns with true, we add the NUL byte manually when printing, and when it returns false, we know there are no NUL bytes any more, and this should be the last piece of data. Tested with Bash 4. The kB wget binary took about 5. In comparison, 's cat-solution finishes in less than 0.
Not very surprising, really. This is obviously silly, since without using external utilities, there's not much we can do with the downloaded file, not even make it executable. So you can also use SSH to upload to it.
Which is functionally equivalent to downloading of software packages etc. As shown in this answer , you would execute the following on your local machine to place a file on your remote headless server:. The disadvantage of the above solution compared to downloading is lower transfer speed, since the connection with your local machine usually has much less bandwidth than the connection between your headless server and other servers. To solve that, you can of course execute the above command on another server with decent bandwidth.
To make that more comfortable avoiding a manual login on the third machine , here is a command to execute on your local machine. See the explanations below for the reason. The command will ssh to your third machine intermediate-host , start downloading a file to there via wget , and start uploading it to target-host via SSH.
Downloading and uploading use the bandwidth of your intermediate-host and happen at the same time due to Bash pipe equivalents , so progress will be fast.
For the -T -e none SSH options when using it to transfer files, see these detailed explanations. This command is meant for cases where you can't use SSH's public key authentication mechanism — it still happens with some shared hosting providers, notably Host Europe.
To still automate the process, we rely on sshpass to be able to supply the password in the command. It requires sshpass to be installed on your intermediate host sudo apt-get install sshpass under Ubuntu.
We try to use sshpass in a secure way, but it will still not be as secure as the SSH pubkey mechanism says man sshpass. In particular, we supply the SSH password not as a command line argument but via a file, which is replaced by bash process substitution to make sure it never exists on disk.
The printf is a bash built-in, making sure this part of the code does not pop up as a separate command in ps output as that would expose the password [ source ]. And that without using a temp file [ source ]. But no guarantees, maybe I overlooked something. Again to make the sshpass usage safe, we need to prevent the command from being recorded to the bash history on your local machine. For that, the whole command is prepended with one space character, which has this effect.
Normally, SSH would then wait for user input to confirm the connection attempt. We make it proceed anyway.
0コメント