Linux Commands

Linux Download File From URL With Password

While working on any type of operating system, we tend to download many files and zip files from the web to the local computer. These files or zip executables could be some text file, some code file, or any executable file for a tool or technology. But, have you ever tried to download any file from a specific URL or webpage to your local computer using the personal password of the website owner? If not! Then this guide is specially designed for your help to experience a new method of downloading files from a web URL to a local bash machine using the shell queries. Let’s get started with the launch of Kali Linux on Windows 10 first. Make sure to install it via the Microsoft store. After installation, it starts from the search bar of your windows desktop and application area. It will take up to 5 seconds to load and start on your desktop screen. The shown below screen will be opened at your end. The bash shell is ready for use.

It’s time to update your Kali Linux first. The update will make your system error-free and more up-to-date with the current functionalities of Linux. We have to try the apt package of bash within the ‘update’ instruction. This instruction shown below must be used with the “sudo” keyword to run it with the root user rights. After executing it, we will be asked to enter the password for the root user that is currently logged in from this Kali Linux system. We have added the password and continued by pressing Enter key. It has started to update our system and get information from the network.

The shown-below last two lines of this query execution will show us the total memory this process took and the time it takes to complete. Now, we are done with the update.

Download File From URL Without Password

Before taking a look at downloading a file within bash from any URL with the password, we will take a simple look at downloading any type of file from the URL without any password. We want to download the “latest.tar.gz” zip file provided by the wordpress.org official site. Downloading this file just doesn’t require any password because this file is for public use. So, we have been utilizing the bash’s wget package followed by the path to the file in our command area to download it. After executing the query shown below, it started collecting information and data of the file until full, i.e., 100%. The last output line shows that the file is saved.

This file must have been saved within the current working directory of our bash system, i.e., Kali Linux. To check that it has been downloaded successfully, we have to try the “ls” list instruction at the bash shell. It will display all the files and folders of our current working directory. This command usage shows that the file has been successfully downloaded.

Download File From URL With Password

Let’s have an example of downloading a file from a webpage that doesn’t allow us to download it in a simple manual way. For instance, we have a business website, “aioshop.pk” on the web, and it has some files in it that we cannot download from it. To download that file from the “aioshop.pk”, we will be using the wget command in the bash shell.

Before that, we have been navigating towards the “downloads” folders using the “cd” instruction. After that, we used the wget command, followed by the option “—user” and “password”. The option “—user” will contain the username for a person who has some admin rights to this site along with its account password that is blurred for security reasons. After both these options, we have added the path to the website page that contains the file. After executing this wget command, it has started to connect our local system with the website first, and after that, it has started to download the particular text file, i.e., robots.txt. After a while, the download has been completed, and it shows that the file is saved in our local bash system.

After listing the data of the downloads directory of our bash system, we have found that the “robots.txt” file from the website “aioshop.pk” has been successfully downloaded within our bash system using the admin user and password.

If you don’t want to add a password in the instruction area to prevent issues regarding the security of the website, you can try another method. This method will be using the “—ask-password” option within the same query instead of the “—password” option that is used to directly add the password. The “—ask-password” option will ask for your account password at the runtime of this instruction, as shown below. After adding the correct password, your file will be started to download, as shown below.

After the full download, we can list it within the downloads folder. If we have downloaded the same file more than one time, it will be saved with the numbers at last in a sequence, i.e., 1, 2.

The same thing can be done with the File Transfer protocol without using the Hypertext transfer protocol used in the path to the file to be downloaded. The same “—ask-password” and “—user” options will be used in the wget command, followed by the path to the file starting with “FTP” instead of “https” as shown.

The file will be successfully downloaded.

Conclusion

This is all about using wget instruction in the Kali Linux bash shell to download files from some specific URLs. We have discussed using a password within the instructions after looking at the use of no password commands. Different options have been used so far.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.