Bootstrap FreeKB - Linux Commands - wget (download files from remote systems)
Linux Commands - wget (download files from remote systems)

Updated:   |  Linux Commands articles

On a Linux System, the most popular ways to transfer a file from one Linux system to another Linux system are:

For example, scp or rsync could be used to transfer example.jpg from Machine 1 to Machine 2, or vice versa.

The Secure FTP (SFTP) command can be used to securely transfer files between Mac, Linux and Windows systems.

The wget command can be used to download files from remote systems to your local Linux system. To put this another way, wget can transfer a file from a remote system to your local Linux system. In this example, the wget command is used to download file1.txt from the web server.

~]# wget 


In this example, the wget command is used to download file2.txt from the FTP server.

~]# wget


Target Directory

The --directory-prefix option can be used to specify the target directory where the file should be stored.

wget --directory-prefix /tmp


Or, the -o or --output-document option can be used which allows you to rename the file too if you would like.

wget --output-document/tmp/new_file_name.txt



Some downloads can take a while. If a download is taking a while, you can switch to another TTY console so that you can continue to interact with the Terminal. Or, you can use the -b or --background option to run wget in the background.

~]# wget -b 



Wget without any options can produce quite a bit of output. The -q or --quiet option can be used to not display any output when running the wget command.

~]# wget -q 


Username Password

If the target system requires a username and password for the resource being requested, the --user and --password options can be used to provide the username and password.

~]# wget --user=the_username --password=the_password


The --ask-password option can be used to prompt for the password when running the command.

~]# wget --ask-password


Also, the /home/username/.wgetrc file can be created, and the username and password can be stored in the .wgetrc file. If the HTTP and FTP username and password is identical, use this format:



If the HTTP and FTP username and password are different, use this format:




When connecting to a secured system, such as an HTTPS web server or an FTPS server, you may get a prompt like this.

~]# wget

ERROR: cannot verify's certificate, issued by /DC=com/DC=example/CN=example:
  Unable to locally verify the issuer's authority.
To connect to insecurely, use `--no-check-certificate'.


As the warning suggests, you can use the --no-check-certificate flag if you want to connect.

wget --no-check-certificate


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter c51be4 in the box below so that we can be sure you are a human.