Home >Operation and Maintenance >Linux Operation and Maintenance >5 wget examples for downloading files on the Linux command line

5 wget examples for downloading files on the Linux command line

不言
不言Original
2019-03-08 14:54:027789browse

wget is a Linux command line utility that is widely used to download files from the Linux command line. There are many options that can be used to download files from remote servers as well. wget is the same as open url in the browser window.

5 wget examples for downloading files on the Linux command line

#1: Use Wget to download files

The following example will download files from the server to the current local directory.

$ wget https://tecadmin.net/file.zip

2: Download the file and save to a specific location

The following command will download the zip file in the /opt folder named file.zip. -O is used to specify the target folder

# wget https://tecadmin.net/file.zip -O /opt/file.zip

3: Download files from FTP

Sometimes you need to download files from ftp server, so wget can easily download files from ftp url Download the file as shown below.

# wget ftp://ftp.tecadmin.net/file.zip

4: Download files from password-protected URL

Sometimes we need to specify username and password to download files. While it's easy to use the browser using the command line, it doesn't prompt for login credentials. The following example will illustrate how to use username, password when downloading a file from a password protected source.

4.1: Download files from password-protected ftp server.

$ wget --ftp-user=username --ftp-password=secretpassword ftp://ftp.tecadmin.net/file.zip
or
$ wget ftp://username:secretpassword@ftp.tecadmin.net/file.zip

4.2: Download files from password protected http server.

# wget --http-user=username --http-password=secretpassword https://tecadmin.net/file.zip
or
# wget --user=username --password=secretpassword https://tecadmin.net/file.zip

4.3: Download files behind a password-protected proxy server.

$ wget --proxy-user=username --proxy-password=secretpassword https://tecadmin.net/file.zip

5: Download files from untrusted secure URLs.

If any download URL uses an untrusted ssl certificate, wget will not download the file. But we can download it using -no-check-certificate parameter in url.

$ wget  https://tecadmin.net/file.zip  --no-check-certificate

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the PHP Chinese website! ! !

The above is the detailed content of 5 wget examples for downloading files on the Linux command line. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn