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 www.example.com web server.
~]# wget http://www.example.com/file1.txt
In this example, the wget command is used to download file2.txt from the example.com FTP server.
~]# wget ftp://example.com/file2.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 http://www.example.com/big.iso
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 ftp://example.com/file3.txt
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 http://www.example.com/file1.txt --user=the_username --password=the_password
The --ask-password option can be used to prompt for the password when running the command.
~]# wget http://www.example.com/file1.txt --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:
ftp_user=your_username ftp_password=your_password http_user=your_username http_password=your_password
When connecting to a secured system, such as an HTTPS web server or an FTPS server, you may get a prompt like this.
~]# wget https://www.example.com/foo.txt ERROR: cannot verify www.example.com's certificate, issued by â€˜/DC=com/DC=example/CN=exampleâ€™: Unable to locally verify the issuer's authority. To connect to www.example.com insecurely, use `--no-check-certificate'.
As the warning suggests, you can use the --no-check-certificate flag if you want to connect.
wget https://www.example.com/foo.txt --no-check-certificate