Wget how to use

Wget how to use

Изучаем команду wget на 12 примерах

Все мы иногда качаем файлы из интернета. Если для этого использовать программы с графическим интерфейсом, то всё оказывается предельно просто. Однако, при работе в командной строке Linux дело несколько усложняется. Особенно — для тех, кто не знаком с подходящими инструментами. Один из таких инструментов — чрезвычайно мощная утилита wget, которая подходит для выполнения всех видов загрузок. Предлагаем вашему вниманию двенадцать примеров, разобрав которые, можно освоить основные возможности wget.

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

1. Загрузка одного файла

Если всё, что нужно — это загрузка одного файла, нам подойдёт следующая конструкция:

После ввода такой команды начнётся скачивание Nagios Core. В ходе этого процесса можно будет видеть данные о загрузке, например — сведения о том, какой объём данных уже загружен, текущую скорость, и то, сколько времени осталось до конца загрузки.

2. Загрузка файла и сохранение его с новым именем

3. Ограничение скорости загрузки файлов

Здесь задано ограничение скорости загрузки, равное 500 Кб/с.

4. Завершение прерванной загрузки

Если этот параметр не использовать, то загрузка недокачанного файла начнётся сначала.

5. Фоновая загрузка файла

6. Загрузка нескольких файлов

Выполнение этой команды приведёт к поочерёдной загрузке всех файлов из списка.

7. Увеличение общего числа попыток загрузки файла

8. Загрузка файлов с FTP-сервера

Команда загрузки файла с анонимного FTP-сервера с помощью wget выглядит так:

Если для доступа к файлу требуются имя пользователя и пароль, то команда примет такой вид:

9. Создание локальной копии веб-сайта

Обратите внимание на дополнительные параметры командной строки:

10. Загрузка с сайта только файлов определённого типа

11. Пропуск файлов определённого типа

Итоги

Wget — довольно простая в использовании, но весьма полезная утилита Linux. И, на самом деле то, о чём мы рассказали — лишь малая часть того, что она умеет. Надеемся, этот обзор поможет тем, кто не был знаком с wget, оценить эту программу, и, возможно, включить её в свой повседневный арсенал инструментов командной строки.

Уважаемые читатели! Пользуетесь ли вы инструментами командной строки Linux для загрузки файлов? Если да — просим о них рассказать.

Linux wget command

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

On Unix-like operating systems, the wget command downloads files served with HTTP, HTTPS, or FTP over a network.

Description

wget is a free utility for non-interactive download of files from the web. It supports HTTP, HTTPS, and FTP protocols, and retrieval through HTTP proxies.

wget is non-interactive, meaning that it can work in the background, while the user is not logged on, which allows you to start a retrieval and disconnect from the system, letting wget finish the work. By contrast, most web browsers require constant user interaction, which make transferring a lot of data difficult.

wget can follow links in HTML and XHTML pages and create local versions of remote websites, fully recreating the directory structure of the original site, which is sometimes called «recursive downloading.» While doing that, wget respects the Robot Exclusion Standard (robots.txt). wget can be instructed to convert the links in downloaded HTML files to the local files for offline viewing.

wget is designed for robustness over slow or unstable network connections; if a download fails due to a network problem, it keeps retrying until the whole file is retrieved. If the server supports regetting, it instructs the server to continue the download from where it left off.

Overview

The simplest way to use wget is to provide it with the location of a file to download over HTTP. For example, to download the file http://website.com/files/file.zip, this command:

. would download the file into the working directory.

There are many options that allow you to use wget in different ways, for different purposes. These are outlined below.

Installing wget

If your operating system is Ubuntu, or another Debian-based Linux distribution which uses APT for package management, you can install wget with apt-get:

For other operating systems, see your package manager’s documentation for information about how to locate the wget binary package and install it. Or, you can install it from source from the GNU official website.

Syntax

Basic startup options

-V, —versionDisplay the version of wget, and exit.
-h, —helpPrint a help message describing all the wget‘s command-line options, and exit.
-b, —backgroundGo to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
-e command,
—execute command
Execute command as if it were a part of the file .wgetrc. A command thus invoked is executed after the commands in .wgetrc, thus taking precedence over them.

Logging and input file options

-o logfile,
—output-file=logfile
Log all messages to logfile. The messages are normally reported to standard error.
-a logfile,
—append-output=logfile
Append to logfile. This option is the same as -o, only it appends to logfile instead of overwriting the old log file. If logfile does not exist, a new file is created.
-d, —debugTurn on debug output, meaning various information important to the developers of wget if it does not work properly. Your system administrator may have chosen to compile wget without debug support, in which case -d does not work.

Note that compiling with debug support is always safe; wget compiled with the debug support does not print any debug info unless requested with -d.-q, —quietTurn off wget‘s output.-v, —verboseTurn on verbose output, with all the available data. The default output is verbose.-nv, —non-verboseNon-verbose output. Turn off verbose without being completely quiet (use -q for that), which means that error messages and basic information still get printed.-i file, —input-file=fileRead URLs from a local or external file. If «» is specified as file, URLs are read from the standard input. (Use «./-» to read from a file literally named ««.)

If this function is used, no URLs need be present on the command line. If there are URLs both on the command line and input file, those on the command lines are the first ones to be retrieved. If —force-html is not specified, then file should consist of a series of URLs, one per line.

However, if you specify —force-html, the document is regarded as HTML. In that case you may have problems with relative links, which you can solve either by adding to the documents or by specifying —base=url on the command line.

If the file is an external one, the document is automatically treated as HTML if the Content-Type is «text/html«. Furthermore, the file’s location is implicitly used as base href if none was specified.-F, —force-htmlWhen input is read from a file, force it to be treated as an HTML file. This enables you to retrieve relative links from existing HTML files on your local disk, by adding to HTML, or using the —base command-line option.-B URL
—base=URLResolves relative links using URL as the point of reference, when reading links from an HTML file specified via the -i/—input-file option (together with —force-html, or when the input file was fetched remotely from a server describing as HTML). This option is equivalent to the presence of a «BASE» tag in the HTML input file, with URL as the value for the «href» attribute.

For instance, if you specify http://foo/bar/a.html for URL, and wget reads ../baz/b.html from the input file, it would be resolved to http://foo/baz/b.html.—config=FILESpecify the location of a startup file you want to use.

Download options

—bind-address=ADDRESSWhen making client TCP/IP connections, bind to ADDRESS on the local machine. ADDRESS may be specified as a hostname or IP address. This option can be useful if your machine is bound to multiple IPs.
-t number, —tries=numberSet number of retries to number. Specify 0 or inf for infinite retrying. The default is to retry 20 times, except for fatal errors like «connection refused» or «not found» (404), which are not retried.
-O file, —output-document=fileThe documents are not written to the appropriate files, but all are concatenated together and written to file.

If «» is used as file, documents are printed to standard output, disabling link conversion. (Use «./-» to print to a file literally named ««.)

For this reason, -N (for timestamp-checking) is not supported in combination with -O: since file is always newly created, it always has a very new timestamp. A warning is issued if this combination is used.

Similarly, using -r or -p with -O may not work as you expect: wget won’t download the first file to file and then download the rest to their normal names: all downloaded content is placed in file. This was disabled in version 1.11, but was reinstated (with a warning) in 1.11.2, as there are some cases where this behavior can actually have some use.

Note that a combination with -k is only permitted when downloading a single document, as in that case, it converts all relative URIs to external ones; -k makes no sense for multiple URIs when they’re all being downloaded to a single file; -k can be used only when the output is a regular file.-nc, —no-clobberIf a file is downloaded more than once in the same directory, wget‘s behavior depends on a few options, including -nc. In certain cases, the local file is «clobbered» (overwritten), upon repeated download. In other cases, it is preserved.

When running wget without -N, -nc, or -r, downloading the same file in the same directory results in the original copy of file being preserved and the second copy being named file.1. If that file is downloaded yet again, the third copy is named file.2, etc. When -nc is specified, this behavior is suppressed, and wget refuses to download newer copies of file. Therefore, «no-clobber» is a misnomer in this mode: it’s not clobbering that’s prevented (as the numeric suffixes were already preventing clobbering), but rather the multiple version saving that’s being turned off.

When running wget with -r, but without -N or -nc, re-downloading a file results in the new copy overwriting the old. Adding -nc prevents this behavior, instead causing the original version to be preserved and any newer copies on the server to be ignored.

When running wget with -N, with or without -r, the decision as to whether or not to download a newer copy of a file depends on the local and remote timestamp and size of the file. -nc may not be specified at the same time as -N.

Note that when -nc is specified, files with the suffixes .html or .htm are loaded from the local disk and parsed as if they had been retrieved from the web.-c, —continueContinue getting a partially-downloaded file. This option is useful when you want to finish up a download started by a previous instance of wget, or by another program. For instance:

If there is a file named ls-lR.Z in the current directory, wget assumes that it is the first portion of the remote file, and asks the server to continue the retrieval from an offset equal to the length of the local file.

Note that you don’t need to specify this option if you only want the current invocation of wget to retry downloading a file should the connection be lost midway through, which is the default behavior. -c only affects resumption of downloads started before this invocation of wget, and whose local files are still sitting around.

Without -c, the previous example would only download the remote file to ls-lR.Z.1, leaving the truncated ls-lR.Z file alone.

Beginning with wget 1.7, if you use -c on a non-empty file, and it turns out that the server does not support continued downloading, wget refuses to start the download from scratch, which would effectively ruin existing contents. If you want the download to start from scratch, remove the file.

Also, beginning with wget 1.7, if you use -c on a file that is of equal size as the one on the server, wget refuses to download the file and print an explanatory message. The same happens when the file is smaller on the server than locally (presumably because it was changed on the server since your last download attempt), because «continuing» is not meaningful, no download occurs.

However, if the file is bigger on the server because it’s been changed, as opposed to appended to, you end up with a garbled file. wget has no way of verifying that the local file is really a valid prefix of the remote file. You need to be especially careful of this when using -c in conjunction with -r, as every file is considered an «incomplete download» candidate.

Another instance where you get a garbled file if you try to use -c is if you have a lame HTTP proxy that inserts a «transfer interrupted» string into the local file. In the future a «rollback» option may be added to deal with this case.

Note that -c only works with FTP servers and with HTTP servers that support the «Range» header.—progress=typeSelect the progress indicator you want to use. Legal indicators are «dot» and «bar«.

The «bar» indicator is used by default. It draws an ASCII progress bar graphics (a.k.a «thermometer» display) indicating the status of retrieval. If the output is not a TTY, the «dot» bar is used by default.

Use —progress=dot to switch to the «dot» display. It traces the retrieval by printing dots on the screen, each dot representing a fixed amount of downloaded data.

When using the dotted retrieval, you may also set the style by specifying the type as dot:style. Different styles assign different meaning to one dot. With the «default» style each dot represents 1 K, there are ten dots in a cluster and 50 dots in a line. The «binary» style has a more «computer»-like orientation: 8 K dots, 16-dots clusters and 48 dots per line (which makes for 384 K lines). The «mega» style is suitable for downloading very large files; each dot represents 6 4K retrieved, there are eight dots in a cluster, and 48 dots on each line (so each line contains 3 M).

Note that you can set the default style using the progress command in .wgetrc. That setting may be overridden from the command line. The exception is that, when the output is not a TTY, the «dot» progress is favored over «bar«. To force the bar output, use —progress=bar:force.-N, —timestampingTurn on time stamping. Output file has a timestamp matching remote copy; if file already exists locally, and remote file is not newer, no download occurs.—no-use-server-timestampsDon’t set the local file’s timestamp by the one on the server.

By default, when a file is downloaded, its timestamps are set to match those from the remote file, which allows the use of —timestamping on subsequent invocations of wget. However, it is sometimes useful to base the local file’s timestamp on when it was downloaded; for that purpose, the —no-use-server-timestamps option is provided.-S, —server-responsePrint the headers sent by HTTP servers and responses sent by FTP servers.—spiderWhen invoked with this option, wget behaves as a web spider, which means it does not download the pages, only checks that they are there. For example, you can use wget to check your bookmarks:

This feature needs much more work for wget to get close to the functionality of real web spiders.-T seconds, —timeout=secondsSet the network timeout to seconds seconds. This option is equivalent to specifying —dns-timeout, —connect-timeout, and —read-timeout, all at the same time.

When interacting with the network, wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings.

All timeout-related options accept decimal values, and subsecond values. For example, 0.1 seconds is a legal (though unwise) choice of timeout. Subsecond timeouts are useful for checking server response times or for testing network latency.—dns-timeout=secondsSet the DNS lookup timeout to seconds seconds. DNS lookups fail if not completed in the specified time. By default, there is no timeout on DNS lookups, other than that implemented by system libraries.—connect-timeout=secondsSet the connect timeout to seconds seconds. TCP connections that take longer to establish are aborted. By default, there is no connect timeout, other than that implemented by system libraries.—read-timeout=secondsSet the read (and write) timeout to seconds seconds. Reads fail if they take longer. The default value for read timeout is 900 seconds.—limit-rate=amountLimit the download speed to amount bytes per second. The amount may be expressed in bytes, kilobytes (with the k suffix), or megabytes (with the m suffix). For example, —limit-rate=20k limits the retrieval rate to 20 KB/s. This option is useful when, for whatever reason, you don’t want wget to consume the entire available bandwidth.

This option allows the use of decimal numbers, usually in conjunction with power suffixes; for example, —limit-rate=2.5k is a legal value.

Note that wget implements the limiting by sleeping the appropriate amount of time after a network read that took less time than specified by the rate. Eventually this strategy causes the TCP transfer to slow down to approximately the specified rate. However, it may take some time for this balance to be achieved, so don’t be surprised if limiting the rate doesn’t work well with very small files.-w seconds, —wait=secondsWait the specified number of seconds between the retrievals. Use of this option is recommended, as it lightens the server load by making the requests less frequent. Instead of in seconds, the time can be specified in minutes using the m suffix, in hours using h suffix, or in days using d suffix.

By default, wget assumes a value of 10 seconds.—random-waitSome websites may perform log analysis to identify retrieval programs such as wget by looking for statistically significant similarities in the time between requests. This option causes the time between requests to vary between 0 and 2*wait seconds, where wait was specified using the —wait option, to mask wget‘s presence from such analysis.

—no-proxyDon’t use proxies, even if the appropriate *_proxy environment variable is defined.-Q quota, —quota=quotaSpecify download quota for automatic retrievals. The value can be specified in bytes (default), kilobytes (with k suffix), or megabytes (with m suffix).

Setting quota to 0 or inf unlimits the download quota.—no-dns-cacheTurn off caching of DNS lookups. Normally, wget remembers the addresses it looked up from DNS so it doesn’t have to repeatedly contact the DNS server for the same (often small) set of addresses it retrieves. This cache exists in memory only; a new wget run contacts DNS again.

However, it was reported that in some situations it is not desirable to cache hostnames, even for the duration of a short-running application like wget. With this option wget issues a new DNS lookup (more precisely, a new call to «gethostbyname» or «getaddrinfo«) each time it makes a new connection. Please note that this option does not affect caching that might be performed by the resolving library or by an external caching layer, such as NSCD.—restrict-file-names=modesChange which characters found in remote URLs may show up in local file names generated from those URLs. Characters that are restricted by this option are escaped, i.e., replaced with %HH, where HH is the hexadecimal number that corresponds to the restricted character.

By default, wget escapes the characters that are not valid as part of file names on your operating system, and control characters that are unprintable. This option is useful for changing these defaults, either because you are downloading to a non-native partition, or because you want to disable escaping of the control characters.

The modes are a comma-separated set of text values. The acceptable values are unix, windows, nocontrol, ascii, lowercase, and uppercase. The values unix and windows are mutually exclusive (one overrides the other), as are lowercase and uppercase. Those last are special cases, as they do not change the set of characters that would be escaped, but rather force local file paths to be converted either to lower or uppercase.

When mode is set to unix, wget escapes the character / and the control characters in the ranges 031 and 128159. This option is the default on Unix-like OSes.

If you specify nocontrol, then the escaping of the control characters is also switched off. This option may make sense when you are downloading URLs whose names contain UTF-8 characters, on a system that can save and display filen ames in UTF-8 (some possible byte values used in UTF-8 byte sequences fall in the range of values designated by wget as «controls»).

The ascii mode is used to specify that any bytes whose values are outside the range of ASCII characters (that is, greater than 127) shall be escaped. This mode can be useful when saving file names whose encoding does not match the one used locally.-4, —inet4-only; -6, —inet6-onlyForce connecting to IPv4 or IPv6 addresses. With —inet4-only or -4, wget only connects to IPv4 hosts, ignoring AAAA records in DNS, and refusing to connect to IPv6 addresses specified in URLs. Conversely, with —inet6-only or -6, wget only connects to IPv6 hosts and ignore A records and IPv4 addresses.

Neither options should be needed normally. By default, an IPv6-aware wget uses the address family specified by the host’s DNS record. If the DNS responds with both IPv4 and IPv6 addresses, wget tries them in sequence until it finds one it can connect to. (Also, see «—prefer-family» option described below.)

These options can deliberately force the use of IPv4 or IPv6 address families on dual family systems, usually to aid debugging or deal with broken network configuration. Only one of —inet6-only and —inet4-only may be specified at the same time. Neither option is available in wget compiled without IPv6 support.—prefer-family=<none|IPv4|IPv6>When given a choice of several addresses, connect to the addresses with specified address family first. The address order returned by DNS is used without change by default.

This avoids spurious errors and connect attempts when accessing hosts that resolve to both IPv6 and IPv4 addresses from IPv4 networks. For example, www.kame.net resolves to 2001:200:0:8002:203:47ff:fea5:3085 and to 203.178.141.194. When the preferred family is «IPv4«, the IPv4 address is used first; when the preferred family is «IPv6«, the IPv6 address is used first; if the specified value is «none«, the address order returned by DNS is used without change.

Unlike -4 and -6, this option doesn’t inhibit access to any address family, it only changes the order in which the addresses are accessed. Also, note that the reordering performed by this option is stable; it doesn’t affect order of addresses of the same family. That is, the relative order of all IPv4 addresses and of all IPv6 addresses remains intact in all cases.—retry-connrefusedConsider «connection refused» a transient error and try again. Normally, wget gives up on a URL when it cannot connect to the site because failure to connect is taken as a sign that the server is not running at all and that retries would not help. This option is for mirroring unreliable sites whose servers tend to disappear for short periods of time.—user=user,
—password=passwordSpecify the username user and password for both FTP and HTTP file retrieval. These parameters can be overridden using the —ftp-user and —ftp-password options for FTP connections and the —http-user and —http-password options for HTTP connections.—ask-passwordPrompt for a password for each connection established. Cannot be specified when —password is used, because they are mutually exclusive.—no-iriTurn off IRI (internationalized URI support. Use —iri to turn it on. IRI support is activated by default.

You can set the default state of IRI support using the «iri» command in .wgetrc. That setting may be overridden from the command line.—local-encoding=encodingForce wget to use encoding as the default system encoding. That affects how wget converts URLs specified as arguments from locale to UTF-8 for IRI support.

wget use the function «nl_langinfo()» and then the «CHARSET» environment variable to get the locale. If it fails, ASCII is used.

You can set the default local encoding using the «local_encoding» command in .wgetrc. That setting may be overridden from the command line.—remote-encoding=encodingForce wget to use encoding as the default remote server encoding. That affects how wget converts URIs found in files from remote encoding to UTF-8 during a recursive fetch. This options is only useful for IRI support, for the interpretation of non-ASCII characters.

For HTTP, remote encoding is in HTTP «Content-Type» header and in HTML «Content-Type http-equiv» meta tag.

You can set the default encoding using the «remoteencoding» command in .wgetrc. That setting may be overridden from the command line.—unlinkForce wget to unlink file instead of clobbering existing file. This option is useful for downloading to the directory with hardlinks.

Directory options

Take, for example, the directory at ftp://ftp.xemacs.org/pub/xemacs/. If you retrieve it with -r, it is saved locally under ftp.xemacs.org/pub/xemacs/. While the -nH option can remove the ftp.xemacs.org/ part, you are still stuck with pub/xemacs, which is where —cut-dirs comes in handy; it makes wget not «see» number remote directory components. Here are several examples of how —cut-dirs option works:

HTTP options

-E, —html-extensionIf a file of type application/xhtml+xml or text/html is downloaded and the URL does not end with the regexp «\.[Hh][Tt][Mm][Ll]?«, this option causes the suffix .html to be appended to the local file name. This option is useful, for instance, when you’re mirroring a remote site that uses .asp pages, but you want the mirrored pages to be viewable on your stock Apache server. Another good use for this is when you’re downloading CGI-generated materials. A URL like http://site.com/article.cgi?25 us saved as article.cgi?25.html.

Note that file names changed in this way are re-downloaded every time you re-mirror a site, because wget can’t tell that the local X.html file corresponds to remote URL X (since it doesn’t yet know that the URL produces output of type text/html or application/xhtml+xml).

As of version 1.12, wget also ensures that any downloaded files of type text/css end in the suffix .css, and the option was renamed from —html-extension, to better reflect its new behavior. The old option name is still acceptable, but should now be considered deprecated.

At some point in the future, this option may be expanded to include suffixes for other types of content, including content types that are not parsed by wget.—http-user=user,
—http-passwd=passwordSpecify the username user and password on an HTTP server. According to the challenge, wget encodes them using either the «basic» (insecure) or the «digest» authentication scheme.

Another way to specify username and password is in the URL itself. Either method reveals your password to anyone who bothers to run ps. To prevent the passwords from being seen, store them in .wgetrc or .netrc, and make sure to protect those files from other users with chmod. If the passwords are important, do not leave them lying in those files either; edit the files and delete them after wget has started the download.—no-cacheDisable server-side cache. In this case, wget sends the remote server an appropriate directive (Pragma: no-cache) to get the file from the remote service, rather than returning the cached version. This option is especially useful for retrieving and flushing out-of-date documents on proxy servers.

Caching is allowed by default.—no-cookiesDisable the use of cookies. Cookies are a mechanism for maintaining server-side state. The server sends the client a cookie using the «Set-Cookie» header, and the client responds with the same cookie upon further requests. Since cookies allow the server owners to keep track of visitors and for sites to exchange this information, some consider them a breach of privacy. The default is to use cookies; however, storing cookies is not on by default.—load-cookies fileLoad cookies from file before the first HTTP retrieval. file is a text file in the format originally used by Netscape’s cookies.txt file.

You often use this option when mirroring sites that require that you be logged in to access some or all their content. The login process works by the web server issuing an HTTP cookie upon receiving and verifying your credentials. The cookie is then resent by the browser when accessing that part of the site, and so proves your identity.

Mirroring such a site requires wget to send the same cookies your browser sends when communicating with the site. To do this use —load-cookies; point wget to the location of the cookies.txt file, and it sends the same cookies your browser would send in the same situation. Different browsers keep text cookie files in different locations:

Netscape 4.xThe cookies are in

/.netscape/cookies.txt.

Mozilla and Netscape 6.xMozilla’s cookie file is also named cookies.txt, located somewhere under

/.mozilla, in the directory of your profile. The full path usually ends up looking somewhat like

/.mozilla/default/some-weird-string/cookies.txt.

Internet ExplorerYou can produce a cookie file that wget can utilize using the file menu, Import and Export, Export Cookies. Tested with Internet Explorer 5 (wow, that’s old), but it is not guaranteed to work with earlier versions.
other browsersIf you are using a different browser to create your cookies, —load-cookies only works if you can locate or produce a cookie file in the Netscape format that wget expects.

If you cannot use —load-cookies, there might still be an alternative. If your browser supports a «cookie manager», you can use it to view the cookies used when accessing the site you’re mirroring. Write down the name and value of the cookie, and manually instruct wget to send those cookies, bypassing the «official» cookie support:

—save-cookies fileSave cookies to file before exiting. This does not save cookies that have expired or that have no expiry time (so-called «session cookies»), but also see —keep-session-cookies.—keep-session-cookiesWhen specified, causes —save-cookies to also save session cookies. Session cookies are normally not saved because they are meant to be kept in memory and forgotten when you exit the browser. Saving them is useful on sites that require you to log in or visit the homepage before you can access some pages. With this option, multiple wget runs are considered a single browser session as far as the site is concerned.

Since the cookie file format does not normally carry session cookies, wget marks them with an expiry timestamp of 0. wget‘s —load-cookies recognizes those as session cookies, but it might confuse other browsers. Also, note that cookies so loaded are treated as other session cookies, which means that if you want —save-cookies to preserve them again, you must use —keep-session-cookies again.—ignore-lengthUnfortunately, some HTTP servers (CGI programs, to be more precise) send out bogus «Content-Length» headers, which makes wget start to bray like a stuck pig, as it thinks not all the document was retrieved. You can spot this syndrome if wget retries getting the same document again and again, each time claiming that the (otherwise normal) connection has closed on the very same byte.

With this option, wget ignores the «Content-Length» header, as if it never existed.—header=header-lineSend header-line with the rest of the headers in each HTTP request. The supplied header is sent as-is, which means it must contain name and value separated by colon, and must not contain newlines.

You may define more than one additional header by specifying —header more than once.

Specification of an empty string as the header value clears all previous user-defined headers.

As of wget 1.10, this option can override headers otherwise generated automatically. This example instructs wget to connect to localhost, but to specify foo.bar in the «Host» header:

In versions of wget before 1.10 such use of —header caused sending of duplicate headers.—max-redirect=numberSpecifies the maximum number of redirections to follow for a resource. The default is 20, which is usually far more than necessary. However, on those occasions where you want to allow more (or fewer), this is the option to use.—proxy-user=user,
—proxy-password=passwordSpecify the username user and password for authentication on a proxy server. wget encodes them using the «basic» authentication scheme.

Security considerations similar to those with —http-password pertain here as well.—referer=urlInclude «Referer: url» header in HTTP request. Useful for retrieving documents with server-side processing that assume they are always being retrieved by interactive web browsers and only come out properly when Referer is set to one of the pages that point to them.—save-headersSave the headers sent by the HTTP server to the file, preceding the actual contents, with an empty line as the separator.-U agent-string,
—user-agent=agent-stringIdentify as agent-string to the HTTP server.

The HTTP protocol allows the clients to identify themselves using a «User-Agent» header field. This enables distinguishing the WWW software, usually for statistical purposes or for tracing of protocol violations. wget normally identifies as «Wget/version«, version being the current version number of wget.

However, some sites are known to impose the policy of tailoring the output according to the «User-Agent«-supplied information. While this is not such a bad idea in theory, it is abused by servers denying information to clients other than (historically) Netscape or, more frequently, Microsoft Internet Explorer. This option allows you to change the «User-Agent» line issued by wget. Use of this option is discouraged, unless you know what you are doing.

Specifying empty user agent with —user-agent=»» instructs wget not to send the «User-Agent» header in HTTP requests.—post-data=string,
—post-file=fileUse POST as the method for all HTTP requests and send the specified data in the request body. —post-data sends string as data, whereas —post-file sends the contents of file. Other than that, they work in the same way. In particular, they both expect content of the form «key1=value1&key2=value2«, with percent-encoding for special characters; the only difference is that one expects its content as a command-line parameter and the other accepts its content from a file. In particular, —post-file is not for transmitting files as form attachments: those must appear as «key=value» data (with appropriate percent-coding) like everything else. wget does not currently support «multipart/form-data» for transmitting POST data; only «application/x-www-form-urlencoded«. Only one of —post-data and —post-file should be specified.

Please be aware that wget needs to know the size of the POST data in advance. Therefore the argument to «—post-file» must be a regular file; specifying a FIFO or something like /dev/stdin won’t work. It’s not quite clear how to work around this limitation inherent in HTTP/1.0. Although HTTP/1.1 introduces chunked transfer that doesn’t require knowing the request length in advance, a client can’t use chunked unless it knows it’s talking to an HTTP/1.1 server. And it can’t know that until it receives a response, which in turn requires the request to be completed, which is sort of a chicken-and-egg problem.

Note that if wget is redirected after the POST request is completed, it does not send the POST data to the redirected URL. Because URLs that process POST often respond with a redirection to a regular page, which does not desire or accept POST. It is not completely clear that this behavior is optimal; if it doesn’t work out, it might be changed in the future.

This example shows how to log to a server using POST and then proceed to download the desired pages, presumably only accessible to authorized users. First, we log in to the server.

And then we grab the page (or pages) we care about:

If the server uses session cookies to track user authentication, the above does not work because —save-cookies does not save them (and neither do browsers) and the cookies.txt file is empty. In that case use —keep-session-cookies along with —save-cookies to force saving of session cookies.—content-dispositionIf this is set, experimental (not fully-functional) support for «Content-Disposition» headers is enabled. This option can currently result in extra round-trips to the server for a «HEAD» request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.

This option is useful for some file-downloading CGI programs that use «Content-Disposition» headers to describe what the name of a downloaded file should be.—trust-server-namesIf this is set on a redirect, the last component of the redirection URL is used as the local file name. By default, it is used the last component in the original URL.—auth-no-challengeIf this option is given, wget sends Basic HTTP authentication information (plaintext username and password) for all requests, like wget 1.10.2 and prior did by default.

Use of this option is not recommended, and is intended only to support some few obscure servers, which never send HTTP authentication challenges, but accept unsolicited auth info, say, in addition to form-based authentication.

HTTPS (SSL/TLS) options

To support encrypted HTTP (HTTPS) downloads, wget must be compiled with an external SSL library, currently OpenSSL. If wget is compiled without SSL support, none of these options are available.

—secure-protocol=protocolChoose the secure protocol to be used. Legal values are auto, SSLv2, SSLv3, and TLSv1. If auto is used, the SSL library is given the liberty of choosing the appropriate protocol automatically, which is achieved by sending an SSLv2 greeting and announcing support for SSLv3 and TLSv1, which the default.

Specifying SSLv2, SSLv3, or TLSv1 forces the use of the corresponding protocol. This option is useful when talking to old and buggy SSL server implementations that make it hard for OpenSSL to choose the correct protocol version. Fortunately, such servers are quite rare.

—no-check-certificateDon’t check the server certificate against the available certificate authorities. Also, don’t require the URL hostname to match the common name presented by the certificate.

As of wget 1.10, the default is to verify the server’s certificate against the recognized certificate authorities, breaking the SSL handshake and aborting the download if the verification fails. Although this provides more secure downloads, it does break interoperability with some sites that worked with previous wget versions, particularly those using self-signed, expired, or otherwise invalid certificates. This option forces an «insecure» mode of operation that turns the certificate verification errors into warnings and allows you to proceed.

If you encounter «certificate verification» errors or ones saying that «common name doesn’t match requested hostname», you can use this option to bypass the verification and proceed with the download. Only use this option if you are otherwise convinced of the site’s authenticity, or if you don’t care about the validity of its certificate. It is often a bad idea not to check the certificates when transmitting confidential or important data.

—certificate=fileUse the client certificate stored in file. This information is needed for servers that are configured to require certificates from the clients that connect to them. Normally a certificate is not required and this switch is optional.
—certificate-type=typeSpecify the type of the client certificate. Legal values are PEM (assumed by default) and DER, also known as ASN1.
—private-key=fileRead the private key from file. This option allows you to provide the private key in a file separate from the certificate.
—private-key-type=typeSpecify the type of the private key. Accepted values are PEM (the default) and DER.
—ca-certificate=fileUse file as the file with the bundle of certificate authorities («CA») to verify the peers. The certificates must be in PEM format.

Without this option wget looks for CA certificates at the system-specified locations, chosen at OpenSSL installation time.

—ca-directory=directorySpecifies directory containing CA certificates in PEM format. Each file contains one CA certificate, and the file name is based on a hash value derived from the certificate. This is achieved by processing a certificate directory with the «c_rehash» utility supplied with OpenSSL. Using —ca-directory is more efficient than —ca-certificate when many certificates are installed because it allows Wget to fetch certificates on demand.

Without this option wget looks for CA certificates at the system-specified locations, chosen at OpenSSL installation time.

—random-file=fileUse file as the source of random data for seeding the pseudorandom number generator on systems without /dev/random.

On such systems the SSL library needs an external source of randomness to initialize. Randomness may be provided by EGD (see —egd-file below) or read from an external source specified by the user. If this option is not specified, wget looks for random data in $RANDFILE or, if that is unset, in $HOME/.rnd. If none of those are available, it is likely that SSL encryption is not usable.

If you’re getting the «Could not seed OpenSSL PRNG; disabling SSL» error, provide random data using some of the methods described above.

—egd-file=fileUse file as the EGD socket. EGD stands for Entropy Gathering Daemon, a user-space program that collects data from various unpredictable system sources and makes it available to other programs that might need it. Encryption software, such as the SSL library, needs sources of non-repeating randomness to seed the random number generator used to produce cryptographically strong keys.

OpenSSL allows the user to specify his own source of entropy using the «RAND_FILE» environment variable. If this variable is unset, or if the specified file does not produce enough randomness, OpenSSL reads random data from EGD socket specified using this option.

If this option is not specified (and the equivalent startup command is not used), EGD is never contacted. EGD is not needed on modern Unix systems that support /dev/random.

FTP options

—ftp-user=user,
—ftp-password=password
Specify the username user and password on an FTP server. Without this, or the corresponding startup option, the password defaults to [email protected], normally used for anonymous FTP.

Another way to specify username and password is in the URL itself. Either method reveals your password to anyone who bothers to run ps. To prevent the passwords from being seen, store them in .wgetrc or .netrc, and make sure to protect those files from other users with chmod. If the passwords are important, do not leave them lying in those files either; edit the files and delete them after wget has started the download.—no-remove-listingDon’t remove the temporary .listing files generated by FTP retrievals. Normally, these files contain the raw directory listings received from FTP servers. Not removing them can be useful for debugging purposes, or when you want to be able to easily check on the contents of remote server directories (e.g., to verify that a mirror you’re running is complete).

Even though this situation isn’t a problem, though, root should never run wget in a non-trusted user’s directory. A user could do something as simple as linking index.html to /etc/passwd and asking root to run wget with -N or -r so the file is overwritten.—no-globTurn off FTP globbing. Globbing refers to the use of shell-like special characters (wildcards), like *, ?, [ and ] to retrieve more than one file from the same directory at once, like:

By default, globbing is turned on if the URL contains a globbing character. This option may be used to turn globbing on or off permanently.

You may have to quote the URL to protect it from being expanded by your shell. Globbing makes wget look for a directory listing, which is system-specific. This is why it currently works only with Unix FTP servers (and the ones emulating Unix ls output).—no-passive-ftpDisable the use of the passive FTP transfer mode. Passive FTP mandates that the client connect to the server to establish the data connection rather than the other way around.

If the machine is connected to the Internet directly, both passive and active FTP should work equally well. Behind most firewall and NAT configurations passive FTP has a better chance of working. However, in some rare firewall configurations, active FTP actually works when passive FTP doesn’t. If you suspect this to be the case, use this option, or set «passive_ftp=off» in your init file.—retr-symlinksUsually, when retrieving FTP directories recursively and a symbolic link is encountered, the linked-to file is not downloaded. Instead, a matching symbolic link is created on the local filesystem. The pointed-to file is not downloaded unless this recursive retrieval would have encountered it separately and still downloaded it.

When —retr-symlinks is specified, however, symbolic links are traversed and the pointed-to files are retrieved. At this time, this option does not cause wget to traverse symlinks to directories and recurse through them, but in the future it should be enhanced to do this.

Note that when retrieving a file (not a directory) because it was specified on the command-line, rather than because it was recursed to, this option has no effect. Symbolic links are always traversed in this case.

Recursive retrieval options

-r, —recursiveTurn on recursive retrieving.
-l depth, —level=depthSpecify recursion maximum depth level depth. The default maximum depth is 5.
—delete-afterThis option tells wget to delete every single file it downloads, after having done so. It is useful for pre-fetching popular pages through a proxy, e.g.:

The -r option is to retrieve recursively, and -nd to not create directories.

Note that —delete-after deletes files on the local machine. It does not issue the DELE FTP command to remote FTP sites, for instance. Also, note that when —delete-after is specified, —convert-links is ignored, so .orig files are not created in the first place.-k, —convert-linksAfter the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc. Note that when —output-document is specified, —convert-links is ignored. Each link is changed in one of the two ways:

1. The links to files that were downloaded by wget are changed to refer to the file they point to as a relative link. Example: if the downloaded file /foo/doc.html links to /bar/img.gif, also downloaded, then the link in doc.html is modified to point to ../bar/img.gif. This kind of transformation works reliably for arbitrary combinations of directories.

2. The links to files that were not downloaded by wget are changed to include hostname and absolute path of the location they point to. Example: if the downloaded file /foo/doc.html links to /bar/img.gif (or ../bar/img.gif), then the link in doc.html is modified to point to http://hostname/bar/img.gif.

Because of this, local browsing works reliably: if a linked file was downloaded, the link refers to its local name; if it was not downloaded, the link refers to its full Internet address rather than presenting a broken link. The fact that the former links are converted to relative links ensures that you can move the downloaded hierarchy to another directory.

For instance, say document 1.html contains an tag referencing 1.gif and an tag pointing to external document 2.html. Say that 2.html is similar but that its image is 2.gif and it links to 3.html. Say this continues up to some arbitrarily high number.

If one executes the command:

then 1.html, 1.gif, 2.html, 2.gif, and 3.html is downloaded. As you can see, 3.html is without its requisite 3.gif because wget is counting the number of hops (up to 2) away from 1.html to determine where to stop the recursion. However, with this command:

all the files above and 3.html‘s requisite 3.gif are downloaded. Similarly,

causes 1.html, 1.gif, 2.html, and 2.gif to be downloaded. One might think that:

would download only 1.html and 1.gif, but unfortunately this is not the case, because -l 0 is equivalent to -l inf; that is, infinite recursion. To download a single HTML page (or a handful of them, all specified on the command-line or in a -i URL input file) and its (or their) requisites, leave off -r and -l:

Note that wget behaves as if -r had been specified, but only that single page and its requisites are downloaded. Links from that page to external documents are not followed. Actually, to download a single page and all its requisites (even if they exist on separate websites), and make sure the lot displays properly locally, this author likes to use a few options in addition to -p:

To finish off this topic, it’s worth knowing that wget‘s idea of an external document link is any URL specified in an tag, an tag, or a tag other than» .—strict-commentsTurn on strict parsing of HTML comments. The default is to terminate comments at the first occurrence of —>.

Until version 1.9, wget interpreted comments strictly, which resulted in missing links in many web pages that displayed fine in browsers, but had the misfortune of containing non-compliant comments. Beginning with version 1.9, wget has joined the ranks of clients that implements «naïve» comments, terminating each comment at the first occurrence of —>.

If, for whatever reason, you want strict comment parsing, use this option to turn it on.

Recursive accept/reject options

-A acclist, —accept acclist;
-R rejlist, —reject rejlist
Specify comma-separated lists of file name suffixes or patterns to accept or reject. Note that if any of the wildcard characters, *, ?, [ or ], appear in an element of acclist or rejlist, it is treated as a pattern, rather than a suffix.
-D domain-list,
—domains=domain-list
Set domains to be followed. domain-list is a comma-separated list of domains. Note that it does not turn on -H.
—exclude-domains domain-listSpecify the domains that are not to be followed.
—follow-ftpFollow FTP links from HTML documents. Without this option, wget ignores all the FTP links.
—follow-tags=listwget has an internal table of HTML tag/attribute pairs that it considers when looking for linked documents during a recursive retrieval. If a user wants only a subset of those tags to be considered, however, he or she should be specify such tags in a comma-separated list with this option.
—ignore-tags=listThis option is the opposite of the —follow-tags option. To skip certain HTML tags when recursively looking for documents to download, specify them in a comma-separated list.

In the past, this option was the best bet for downloading a single page and its requisites, using a command-line like:

However, the author of this option came across a page with tags like » » and came to the realization that specifying tags to ignore was not enough. One can’t tell wget to ignore » «, because then stylesheets are not downloaded. Now the best bet for downloading a single page and its requisites is the dedicated —page-requisites option.—ignore-caseIgnore case when matching files and directories. This influences the behavior of -R, -A, -I, and -X options, and globbing implemented when downloading from FTP sites. For example, with this option, -A *.txt matches file1.txt, but also file2.TXT, file3.TxT, etc.-H—span-hostsEnable spanning across hosts when doing recursive retrieving.-L—relativeFollow relative links only. Useful for retrieving a specific homepage without any distractions, not even those from the same hosts.-I list,
—include-directories=listSpecify a comma-separated list of directories you want to follow when downloading. Elements of list may contain wildcards.-X list,
—exclude-directories=listSpecify a comma-separated list of directories you want to exclude from download. Elements of list may contain wildcards.-np, —no-parentDo not ever ascend to the parent directory when retrieving recursively. This option is a useful option, as it guarantees that only the files below a certain hierarchy are downloaded.

Files

/etc/wgetrcDefault location of the global startup file.
.wgetrcUser startup file.

Examples

Download the default homepage file (index.htm) from www.computerhope.com. The file is saved to the working directory.

Download the file archive.zip from www.example.org, and limit bandwidth usage of the download to 200k/s.

Download archive.zip from example.org, and if a partial download exists in the current directory, resume the download where it left off.

Download archive.zip in the background, returning you to the command prompt in the interim.

Uses «web spider» mode to check if a remote file exists. Output resembles the following:

Download a complete mirror of the website www.example.org to the folder ./example-mirror for local viewing.

Stop downloading archive.zip once five megabytes are successfully transferred. This transfer can then later be resumed using the -c option.

Related commands

curl — Transfer data to or from a server.

GNU Wget 1.21.1-dirty Manual

Table of Contents

Wget 1.21.1-dirty

This file documents the GNU Wget utility for downloading network data.

Copyright © 1996–2011, 2015, 2018–2021 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

• OverviewFeatures of Wget.
• InvokingWget command-line arguments.
• Recursive DownloadDownloading interlinked pages.
• Following LinksThe available methods of chasing links.
• Time-StampingMirroring according to time-stamps.
• Startup FileWget’s initialization file.
• ExamplesExamples of usage.
• VariousThe stuff that doesn’t fit anywhere else.
• AppendicesSome useful references.
• Copying this manualYou may give out copies of this manual.
• Concept IndexTopics covered by this manual.

1 Overview

GNU Wget is a free utility for non-interactive download of files from the Web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies.

This chapter is a partial overview of Wget’s features.

2 Invoking

By default, Wget is very simple to invoke. The basic syntax is:

Wget will simply download all the URLs specified on the command line. URL is a Uniform Resource Locator, as defined below.

2.1 URL Format

URL is an acronym for Uniform Resource Locator. A uniform resource locator is a compact string representation for a resource available via the Internet. Wget recognizes the URL syntax as per RFC1738. This is the most widely used form (square brackets denote optional parts):

You can also encode your username and password within a URL:

You can encode unsafe characters in a URL as ‘ %xy ’, xy being the hexadecimal representation of the character’s ASCII value. Some common unsafe characters include ‘ % ’ (quoted as ‘ %25 ’), ‘ : ’ (quoted as ‘ %3A ’), and ‘ @ ’ (quoted as ‘ %40 ’). Refer to RFC1738 for a comprehensive list of unsafe characters.

Wget also supports the type feature for FTP URLs. By default, FTP documents are retrieved in the binary mode (type ‘ i ’), which means that they are downloaded unchanged. Another useful mode is the ‘ a ’ (ASCII) mode, which converts the line delimiters between the different operating systems, and is thus useful for text files. Here is an example:

Two alternative variants of URL specification are also supported, because of historical (hysterical?) reasons and their widespreaded use.

FTP-only syntax (supported by NcFTP ):

HTTP-only syntax (introduced by Netscape ):

These two alternative forms are deprecated, and may cease being supported in the future.

2.2 Option Syntax

Since Wget uses GNU getopt to process command-line arguments, every option has a long form along with the short one. Long options are more convenient to remember, but take time to type. You may freely mix different option styles, or specify options after the command-line arguments. Thus you may write:

You may put several options that do not require arguments together, like:

This is completely equivalent to:

2.3 Basic Startup Options

Display the version of Wget.

Print a help message describing all of Wget’s command-line options.

2.4 Logging and Input File Options

Turn off Wget’s output.

Turn on verbose output, with all the available data. The default output is verbose.

If the file is an external one, the document will be automatically treated as ‘ html ’ if the Content-Type matches ‘ text/html ’. Furthermore, the file ’s location will be implicitly used as base href if none was specified.

Issues HTTP HEAD request instead of GET and extracts Metalink metadata from response headers. Then it switches to Metalink download. If no valid Metalink metadata is found, it falls back to ordinary HTTP download. Enables ‘ Content-Type: application/metalink4+xml ’ files download/processing.

Set preferred location for Metalink resources. This has effect if multiple resources with same priority are available.

Enable use of file system’s extended attributes to save the original URL and the Referer HTTP header value if used.

Be aware that the URL might contain private information like access tokens or credentials.

Specify the location of a startup file you wish to use instead of the default one(s). Use –no-config to disable reading of config files. If both –config and –no-config are given, –no-config is ignored.

Logs all URL rejections to logfile as comma separated values. The values include the reason of rejection, the URL and the parent URL it was found in.

2.5 Download Options

When making client TCP/IP connections, bind to ADDRESS on the local machine. ADDRESS may be specified as a hostname or IP address. This option can be useful if your machine is bound to multiple IPs.

[libcares only] The given address(es) override the standard nameserver addresses, e.g. as configured in /etc/resolv.conf. ADDRESSES may be specified either as IPv4 or IPv6 addresses, comma-separated. Wget needs to be built with libcares for this option to be available.

Continue getting a partially-downloaded file. This is useful when you want to finish up a download started by a previous instance of Wget, or by another program. For instance:

If there is a file named ls-lR.Z in the current directory, Wget will assume that it is the first portion of the remote file, and will ask the server to continue the retrieval from an offset equal to the length of the local file.

Select the type of the progress indicator you wish to use. Legal indicators are “dot” and “bar”.

The “bar” indicator is used by default. It draws an ASCII progress bar graphics (a.k.a “thermometer” display) indicating the status of retrieval. If the output is not a TTY, the “dot” bar will be used by default.

When using the dotted retrieval, you may set the style by specifying the type as ‘ dot: style ’. Different styles assign different meaning to one dot. With the default style each dot represents 1K, there are ten dots in a cluster and 50 dots in a line. The binary style has a more “computer”-like orientation—8K dots, 16-dots clusters and 48 dots per line (which makes for 384K lines). The mega style is suitable for downloading large files—each dot represents 64K retrieved, there are eight dots in a cluster, and 48 dots on each line (so each line contains 3M). If mega is not enough then you can use the giga style—each dot represents 1M retrieved, there are eight dots in a cluster, and 32 dots on each line (so each line contains 32M).

Force wget to display the progress bar in any verbosity.

Turn on time-stamping. See Time-Stamping, for details.

Don’t set the local file’s timestamp by the one on the server.

Print the headers sent by HTTP servers and responses sent by FTP servers.

When invoked with this option, Wget will behave as a Web spider, which means that it will not download the pages, just check that they are there. For example, you can use Wget to check your bookmarks:

This feature needs much more work for Wget to get close to the functionality of real web spiders.

When interacting with the network, Wget can check for timeout and abort the operation if it takes too long. This prevents anomalies like hanging reads and infinite connects. The only timeout enabled by default is a 900-second read timeout. Setting a timeout to 0 disables it altogether. Unless you know what you are doing, it is best not to change the default timeout settings.

All timeout-related options accept decimal values, as well as subsecond values. For example, ‘ 0.1 ’ seconds is a legal (though unwise) choice of timeout. Subsecond timeouts are useful for checking server response times or for testing network latency.

Set the DNS lookup timeout to seconds seconds. DNS lookups that don’t complete within the specified time will fail. By default, there is no timeout on DNS lookups, other than that implemented by system libraries.

Set the connect timeout to seconds seconds. TCP connections that take longer to establish will be aborted. By default, there is no connect timeout, other than that implemented by system libraries.

Set the read (and write) timeout to seconds seconds. The “time” of this timeout refers to idle time: if, at any point in the download, no data is received for more than the specified number of seconds, reading fails and the download is restarted. This option does not directly affect the duration of the entire download.

Of course, the remote server may choose to terminate the connection sooner than this option requires. The default read timeout is 900 seconds.

Note that Wget implements the limiting by sleeping the appropriate amount of time after a network read that took less time than specified by the rate. Eventually this strategy causes the TCP transfer to slow down to approximately the specified rate. However, it may take some time for this balance to be achieved, so don’t be surprised if limiting the rate doesn’t work well with very small files.

Wait the specified number of seconds between the retrievals. Use of this option is recommended, as it lightens the server load by making the requests less frequent. Instead of in seconds, the time can be specified in minutes using the m suffix, in hours using h suffix, or in days using d suffix.

If you don’t want Wget to wait between every retrieval, but only between retries of failed downloads, you can use this option. Wget will use linear backoff, waiting 1 second after the first failure on a given file, then waiting 2 seconds after the second failure on that file, up to the maximum number of seconds you specify.

By default, Wget will assume a value of 10 seconds.

A 2001 article in a publication devoted to development on a popular consumer platform provided code to perform this analysis on the fly. Its author suggested blocking at the class C address level to ensure automated retrieval programs were blocked despite changing DHCP-supplied addresses.

Don’t use proxies, even if the appropriate *_proxy environment variable is defined.

See Proxies, for more information about the use of proxies with Wget.

Specify download quota for automatic retrievals. The value can be specified in bytes (default), kilobytes (with ‘ k ’ suffix), or megabytes (with ‘ m ’ suffix).

Setting quota to 0 or to ‘ inf ’ unlimits the download quota.

Turn off caching of DNS lookups. Normally, Wget remembers the IP addresses it looked up from DNS so it doesn’t have to repeatedly contact the DNS server for the same (typically small) set of hosts it retrieves from. This cache exists in memory only; a new Wget run will contact DNS again.

However, it has been reported that in some situations it is not desirable to cache host names, even for the duration of a short-running application like Wget. With this option Wget issues a new DNS lookup (more precisely, a new call to gethostbyname or getaddrinfo ) each time it makes a new connection. Please note that this option will not affect caching that might be performed by the resolving library or by an external caching layer, such as NSCD.

If you don’t understand exactly what this option does, you probably won’t need it.

Change which characters found in remote URLs must be escaped during generation of local filenames. Characters that are restricted by this option are escaped, i.e. replaced with ‘ %HH ’, where ‘ HH ’ is the hexadecimal number that corresponds to the restricted character. This option may also be used to force all alphabetical cases to be either lower- or uppercase.

By default, Wget escapes the characters that are not valid or safe as part of file names on your operating system, as well as control characters that are typically unprintable. This option is useful for changing these defaults, perhaps because you are downloading to a non-native partition, or because you want to disable escaping of the control characters, or you want to further restrict characters to only those in the ASCII range of values.

The modes are a comma-separated set of text values. The acceptable values are ‘ unix ’, ‘ windows ’, ‘ nocontrol ’, ‘ ascii ’, ‘ lowercase ’, and ‘ uppercase ’. The values ‘ unix ’ and ‘ windows ’ are mutually exclusive (one will override the other), as are ‘ lowercase ’ and ‘ uppercase ’. Those last are special cases, as they do not change the set of characters that would be escaped, but rather force local file paths to be converted either to lower- or uppercase.

When “unix” is specified, Wget escapes the character ‘ / ’ and the control characters in the ranges 0–31 and 128–159. This is the default on Unix-like operating systems.

If you specify ‘ nocontrol ’, then the escaping of the control characters is also switched off. This option may make sense when you are downloading URLs whose names contain UTF-8 characters, on a system which can save and display filenames in UTF-8 (some possible byte values used in UTF-8 byte sequences fall in the range of values designated by Wget as “controls”).

The ‘ ascii ’ mode is used to specify that any bytes whose values are outside the range of ASCII characters (that is, greater than 127) shall be escaped. This can be useful when saving filenames whose encoding does not match the one used locally.

When given a choice of several addresses, connect to the addresses with specified address family first. The address order returned by DNS is used without change by default.

Consider “connection refused” a transient error and try again. Normally Wget gives up on a URL when it is unable to connect to the site because failure to connect is taken as a sign that the server is not running at all and that retries would not help. This option is for mirroring unreliable sites whose servers tend to disappear for short periods of time.

Prompt for a user and password using the specified command. If no command is specified then the command in the environment variable WGET_ASKPASS is used. If WGET_ASKPASS is not set then the command in the environment variable SSH_ASKPASS is used.

Force Wget to use encoding as the default system encoding. That affects how Wget converts URLs specified as arguments from locale to UTF-8 for IRI support.

Wget use the function nl_langinfo() and then the CHARSET environment variable to get the locale. If it fails, ASCII is used.

Force Wget to use encoding as the default remote server encoding. That affects how Wget converts URIs found in files from remote encoding to UTF-8 during a recursive fetch. This options is only useful for IRI support, for the interpretation of non-ASCII characters.

For HTTP, remote encoding can be found in HTTP Content-Type header and in HTML Content-Type http-equiv meta tag.

Force Wget to unlink file instead of clobbering existing file. This option is useful for downloading to the directory with hardlinks.

2.6 Directory Options

Ignore number directory components. This is useful for getting a fine-grained control over the directory where recursive retrieval will be saved.

2.7 HTTP Options

At some point in the future, this option may well be expanded to include suffixes for other types of content, including content types that are not parsed by Wget.

Turn off the “keep-alive” feature for HTTP downloads. Normally, Wget asks the server to keep the connection open so that, when you download more than one document from the same server, they get transferred over the same TCP connection. This saves time and at the same time reduces the load on the server.

This option is useful when, for some reason, persistent (keep-alive) connections don’t work for you, for example due to a server bug or due to the inability of server-side scripts to cope with the connections.

Disable server-side cache. In this case, Wget will send the remote server appropriate directives (‘ Cache-Control: no-cache ’ and ‘ Pragma: no-cache ’) to get the file from the remote service, rather than returning the cached version. This is especially useful for retrieving and flushing out-of-date documents on proxy servers.

Caching is allowed by default.

Disable the use of cookies. Cookies are a mechanism for maintaining server-side state. The server sends the client a cookie using the Set-Cookie header, and the client responds with the same cookie upon further requests. Since cookies allow the server owners to keep track of visitors and for sites to exchange this information, some consider them a breach of privacy. The default is to use cookies; however, storing cookies is not on by default.

Load cookies from file before the first HTTP retrieval. file is a textual file in the format originally used by Netscape’s cookies.txt file.

You will typically use this option when mirroring sites that require that you be logged in to access some or all of their content. The login process typically works by the web server issuing an HTTP cookie upon receiving and verifying your credentials. The cookie is then resent by the browser when accessing that part of the site, and so proves your identity.

The cookies are in

Mozilla and Netscape 6.x.

You can produce a cookie file Wget can use by using the File menu, Import and Export, Export Cookies. This has been tested with Internet Explorer 5; it is not guaranteed to work with earlier versions.

Unfortunately, some HTTP servers (CGI programs, to be more precise) send out bogus Content-Length headers, which makes Wget go wild, as it thinks not all the document was retrieved. You can spot this syndrome if Wget retries getting the same document again and again, each time claiming that the (otherwise normal) connection has closed on the very same byte.

With this option, Wget will ignore the Content-Length header—as if it never existed.

Send header-line along with the rest of the headers in each HTTP request. The supplied header is sent as-is, which means it must contain name and value separated by colon, and must not contain newlines.

Specification of an empty string as the header value will clear all previous user-defined headers.

As of Wget 1.10, this option can be used to override headers otherwise generated automatically. This example instructs Wget to connect to localhost, but to specify ‘ foo.bar ’ in the Host header:

Choose the type of compression to be used. Legal values are ‘ auto ’, ‘ gzip ’ and ‘ none ’.

If ‘ auto ’ or ‘ gzip ’ are specified, Wget asks the server to compress the file using the gzip compression format. If the server compresses the file and responds with the Content-Encoding header field set appropriately, the file will be decompressed automatically.

If ‘ none ’ is specified, wget will not ask the server to compress the file and will not decompress any server responses. This is the default.

Specifies the maximum number of redirections to follow for a resource. The default is 20, which is usually far more than necessary. However, on those occasions where you want to allow more (or fewer), this is the option to use.

Specify the username user and password password for authentication on a proxy server. Wget will encode them using the basic authentication scheme.

Include ‘Referer: url ’ header in HTTP request. Useful for retrieving documents with server-side processing that assume they are always being retrieved by interactive web browsers and only come out properly when Referer is set to one of the pages that point to them.

Save the headers sent by the HTTP server to the file, preceding the actual contents, with an empty line as the separator.

Identify as agent-string to the HTTP server.

The HTTP protocol allows the clients to identify themselves using a User-Agent header field. This enables distinguishing the WWW software, usually for statistical purposes or for tracing of protocol violations. Wget normally identifies as ‘ Wget/ version ’, version being the current version number of Wget.

Note: As of version 1.15 if Wget is redirected after the POST request is completed, its behaviour will depend on the response code returned by the server. In case of a 301 Moved Permanently, 302 Moved Temporarily or 307 Temporary Redirect, Wget will, in accordance with RFC2616, continue to send a POST request. In case a server wants the client to change the Request method upon redirection, it should send a 303 See Other response code.

This example shows how to log in to a server using POST and then proceed to download the desired pages, presumably only accessible to authorized users:

If this is set to on, experimental (not fully-functional) support for Content-Disposition headers is enabled. This can currently result in extra round-trips to the server for a HEAD request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.

This option is useful for some file-downloading CGI programs that use Content-Disposition headers to describe what the name of a downloaded file should be.

If this is set to on, wget will not skip the content when the server responds with a http status code that indicates error.

If this is set, on a redirect, the local file name will be based on the redirection URL. By default the local file name is based on the original URL. When doing recursive retrieving this can be helpful because in many web sites redirected URLs correspond to an underlying file structure, while link URLs do not.

If this option is given, Wget will send Basic HTTP authentication information (plaintext username and password) for all requests, just like Wget 1.10.2 and prior did by default.

Use of this option is not recommended, and is intended only to support some few obscure servers, which never send HTTP authentication challenges, but accept unsolicited auth info, say, in addition to form-based authentication.

Consider host errors, such as “Temporary failure in name resolution”, as non-fatal, transient errors.

Consider given HTTP response codes as non-fatal, transient errors. Supply a comma-separated list of 3-digit HTTP response codes as argument. Useful to work around special circumstances where retries are required, but the server responds with an error code normally not retried by Wget. Such errors might be 503 (Service Unavailable) and 429 (Too Many Requests). Retries enabled by this option are performed subject to the normal retry timing and retry count limitations of Wget.

Using this option is intended to support special use cases only and is generally not recommended, as it can force retries even in cases where the server is actually trying to decrease its load. Please use wisely and only if you know what you are doing.

2.8 HTTPS (SSL/TLS) Options

To support encrypted HTTP (HTTPS) downloads, Wget must be compiled with an external SSL library. The current default is GnuTLS. In addition, Wget also supports HSTS (HTTP Strict Transport Security). If Wget is compiled without SSL support, none of these options are available.

Choose the secure protocol to be used. Legal values are ‘ auto ’, ‘ SSLv2 ’, ‘ SSLv3 ’, ‘ TLSv1 ’, ‘ TLSv1_1 ’, ‘ TLSv1_2 ’, ‘ TLSv1_3 ’ and ‘ PFS ’. If ‘ auto ’ is used, the SSL library is given the liberty of choosing the appropriate protocol automatically, which is achieved by sending a TLSv1 greeting. This is the default.

Specifying ‘ SSLv2 ’, ‘ SSLv3 ’, ‘ TLSv1 ’, ‘ TLSv1_1 ’, ‘ TLSv1_2 ’ or ‘ TLSv1_3 ’ forces the use of the corresponding protocol. This is useful when talking to old and buggy SSL server implementations that make it hard for the underlying SSL library to choose the correct protocol version. Fortunately, such servers are quite rare.

Specifying ‘ PFS ’ enforces the use of the so-called Perfect Forward Security cipher suites. In short, PFS adds security by creating a one-time key for each SSL connection. It has a bit more CPU impact on client and server. We use known to be secure ciphers (e.g. no MD4) and the TLS protocol. This mode also explicitly excludes non-PFS key exchange methods, such as RSA.

When in recursive mode, only HTTPS links are followed.

Set the cipher list string. Typically this string sets the cipher suites and other SSL/TLS options that the user wish should be used, in a set order of preference (GnuTLS calls it ’priority string’). This string will be fed verbatim to the SSL/TLS engine (OpenSSL or GnuTLS) and hence its format and syntax is dependent on that. Wget will not process or manipulate it in any way. Refer to the OpenSSL or GnuTLS documentation for more information.

Don’t check the server certificate against the available certificate authorities. Also don’t require the URL host name to match the common name presented by the certificate.

As of Wget 1.10, the default is to verify the server’s certificate against the recognized certificate authorities, breaking the SSL handshake and aborting the download if the verification fails. Although this provides more secure downloads, it does break interoperability with some sites that worked with previous Wget versions, particularly those using self-signed, expired, or otherwise invalid certificates. This option forces an “insecure” mode of operation that turns the certificate verification errors into warnings and allows you to proceed.

If you encounter “certificate verification” errors or ones saying that “common name doesn’t match requested host name”, you can use this option to bypass the verification and proceed with the download. Only use this option if you are otherwise convinced of the site’s authenticity, or if you really don’t care about the validity of its certificate. It is almost always a bad idea not to check the certificates when transmitting confidential or important data. For self-signed/internal certificates, you should download the certificate and verify against that instead of forcing this insecure mode. If you are really sure of not desiring any certificate verification, you can specify –check-certificate=quiet to tell wget to not print any warning about invalid certificates, albeit in most cases this is the wrong thing to do.

Specify the type of the client certificate. Legal values are ‘ PEM ’ (assumed by default) and ‘ DER ’, also known as ‘ ASN1 ’.

Specify the type of the private key. Accepted values are ‘ PEM ’ (the default) and ‘ DER ’.

Use file as the file with the bundle of certificate authorities (“CA”) to verify the peers. The certificates must be in PEM format.

Without this option Wget looks for CA certificates at the system-specified locations, chosen at OpenSSL installation time.

Without this option Wget looks for CA certificates at the system-specified locations, chosen at OpenSSL installation time.

Tells wget to use the specified public key file (or hashes) to verify the peer. This can be a path to a file which contains a single public key in PEM or DER format, or any number of base64 encoded sha256 hashes preceded by “sha256//” and separated by “;”

When negotiating a TLS or SSL connection, the server sends a certificate indicating its identity. A public key is extracted from this certificate and if it does not exactly match the public key(s) provided to this option, wget will abort the connection before sending or receiving any data.

If you’re getting the “Could not seed OpenSSL PRNG; disabling SSL.” error, you should provide random data using some of the methods described above.

[OpenSSL only] Use file as the EGD socket. EGD stands for Entropy Gathering Daemon, a user-space program that collects data from various unpredictable system sources and makes it available to other programs that might need it. Encryption software, such as the SSL library, needs sources of non-repeating randomness to seed the random number generator used to produce cryptographically strong keys.

OpenSSL allows the user to specify his own source of entropy using the RAND_FILE environment variable. If this variable is unset, or if the specified file does not produce enough randomness, OpenSSL will read random data from EGD socket specified using this option.

By default, Wget stores its HSTS database in

The Wget’s HSTS database is a plain text file. Each line contains an HSTS entry (ie. a site that has issued a Strict-Transport-Security header and that therefore has specified a concrete HSTS policy to be applied). Lines starting with a dash ( # ) are ignored by Wget. Please note that in spite of this convenient human-readability hand-hacking the HSTS database is generally not a good idea.

An HSTS entry line consists of several fields separated by one or more whitespace:

If the supplied file does not exist, Wget will create one. This file will contain the new HSTS entries. If no HSTS entries were generated (no Strict-Transport-Security headers were sent by any of the servers) then no file will be created, not even an empty one. This behaviour applies to the default database file (

/.wget-hsts ) as well: it will not be created until some server enforces an HSTS policy.

Care is taken not to override possible changes made by other Wget processes at the same time over the HSTS database. Before dumping the updated HSTS entries on the file, Wget will re-read it and merge the changes.

Using a custom HSTS database and/or modifying an existing one is discouraged. For more information about the potential security threats arose from such practice, see section 14 «Security Considerations» of RFC 6797, specially section 14.9 «Creative Manipulation of HSTS Policy Store».

Use file as the destination WARC file.

Use string into as the warcinfo record.

Write CDX index files.

Do not store records listed in this CDX file.

Do not compress WARC files with GZIP.

Do not calculate SHA1 digests.

Do not store the log file in a WARC record.

Specify the location for temporary files created by the WARC writer.

2.9 FTP Options

By default, globbing will be turned on if the URL contains a globbing character. This option may be used to turn globbing on or off permanently.

You may have to quote the URL to protect it from being expanded by your shell. Globbing makes Wget look for a directory listing, which is system-specific. This is why it currently works only with Unix FTP servers (and the ones emulating Unix ls output).

Disable the use of the passive FTP transfer mode. Passive FTP mandates that the client connect to the server to establish the data connection rather than the other way around.

If the machine is connected to the Internet directly, both passive and active FTP should work equally well. Behind most firewall and NAT configurations passive FTP has a better chance of working. However, in some rare firewall configurations, active FTP actually works when passive FTP doesn’t. If you suspect this to be the case, use this option, or set passive_ftp=off in your init file.

Preserve remote file permissions instead of permissions set by umask.

By default, when retrieving FTP directories recursively and a symbolic link is encountered, the symbolic link is traversed and the pointed-to files are retrieved. Currently, Wget does not traverse symbolic links to directories to download them recursively, though this feature may be added in the future.

Note that when retrieving a file (not a directory) because it was specified on the command-line, rather than because it was recursed to, this option has no effect. Symbolic links are always traversed in this case.

2.10 FTPS Options

All the data connections will be in plain text. Only the control connection will be under SSL/TLS. Wget will send a PROT C command to achieve this, which must be approved by the server.

Fall back to FTP if FTPS is not supported by the target server. For security reasons, this option is not asserted by default. The default behaviour is to exit with an error. If a server does not successfully reply to the initial AUTH TLS command, or in the case of implicit FTPS, if the initial SSL/TLS connection attempt is rejected, it is considered that such server does not support FTPS.

2.11 Recursive Retrieval Options

Turn on recursive retrieving. See Recursive Download, for more details. The default maximum depth is 5.

This option tells Wget to delete every single file it downloads, after having done so. It is useful for pre-fetching popular pages through a proxy, e.g.:

After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc.

Each link will be changed in one of the two ways:

Because of this, local browsing works reliably: if a linked file was downloaded, the link will refer to its local name; if it was not downloaded, the link will refer to its full Internet address rather than presenting a broken link. The fact that the former links are converted to relative links ensures that you can move the downloaded hierarchy to another directory.

This option converts only the filename part of the URLs, leaving the rest of the URLs untouched. This filename part is sometimes referred to as the «basename», although we avoid that term here in order not to cause confusion.

This option causes Wget to download all the files that are necessary to properly display a given HTML page. This includes such things as inlined images, sounds, and referenced stylesheets.

If one executes the command:

all the above files and 3.html ’s requisite 3.gif will be downloaded. Similarly,

If, for whatever reason, you want strict comment parsing, use this option to turn it on.

2.12 Recursive Accept/Reject Options

Specify a regular expression to accept or reject the complete URL.

Specify the regular expression type. Possible types are ‘ posix ’ or ‘ pcre ’. Note that to be able to use ‘ pcre ’ type, wget has to be compiled with libpcre support.

Specify the domains that are not to be followed (see Spanning Hosts).

Follow FTP links from HTML documents. Without this option, Wget will ignore all the FTP links.

Wget has an internal table of HTML tag / attribute pairs that it considers when looking for linked documents during a recursive retrieval. If a user wants only a subset of those tags to be considered, however, he or she should be specify such tags in a comma-separated list with this option.

In the past, this option was the best bet for downloading a single page and its requisites, using a command-line like:

Enable spanning across hosts when doing recursive retrieving (see Spanning Hosts).

Follow relative links only. Useful for retrieving a specific home page without any distractions, not even those from the same hosts (see Relative Links).

Specify a comma-separated list of directories you wish to follow when downloading (see Directory-Based Limits). Elements of list may contain wildcards.

Specify a comma-separated list of directories you wish to exclude from download (see Directory-Based Limits). Elements of list may contain wildcards.

Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded. See Directory-Based Limits, for more details.

2.13 Exit Status

Wget may return one of several error codes if it encounters problems.

No problems occurred.

Generic error code.

SSL verification failure.

Username/password authentication failure.

Server issued an error response.

With the exceptions of 0 and 1, the lower-numbered exit codes take precedence over higher-numbered ones, when multiple types of errors are encountered.

In versions of Wget prior to 1.12, Wget’s exit status tended to be unhelpful and inconsistent. Recursive downloads would virtually always return 0 (success), regardless of any issues encountered, and non-recursive fetches only returned the status corresponding to the most recently-attempted download.

3 Recursive Download

GNU Wget is capable of traversing parts of the Web (or a single HTTP or FTP server), following links and directory structure. We refer to this as to recursive retrieval, or recursion.

Recursive retrieval of HTTP and HTML/CSS content is breadth-first. This means that Wget first downloads the requested document, then the documents linked from that document, then the documents linked by them, and so on. In other words, Wget first downloads the documents at depth 1, then those at depth 2, and so on until the specified maximum depth.

When retrieving an FTP URL recursively, Wget will retrieve all the data from the given directory tree (including the subdirectories up to the specified depth) on the remote server, creating its mirror image locally. FTP retrieval is also limited by the depth parameter. Unlike HTTP recursion, FTP recursion is performed depth-first.

By default, Wget will create a local directory tree, corresponding to the one found on the remote server.

Recursive retrieving can find a number of applications, the most important of which is mirroring. It is also useful for WWW presentations, and any other opportunities where slow network connections should be bypassed by storing the files locally.

Of course, recursive download may cause problems on your machine. If left to run unchecked, it can easily fill up the disk. If downloading from local network, it can also take bandwidth on the system, as well as consume memory and CPU.

Recursive retrieval should be used with care. Don’t say you were not warned.

4 Following Links

When retrieving recursively, one does not wish to retrieve loads of unnecessary data. Most of the time the users bear in mind exactly what they want to download, and want Wget to follow only specific links.

For example, if you wish to download the music archive from ‘ fly.srk.fer.hr ’, you will not want to download all the home pages that happen to be referenced by an obscure part of the archive.

Wget possesses several mechanisms that allows you to fine-tune which links it will follow.

• Spanning Hosts(Un)limiting retrieval based on host name.
• Types of FilesGetting only certain files.
• Directory-Based LimitsGetting only certain directories.
• Relative LinksFollow relative links only.
• FTP LinksFollowing FTP links.

4.1 Spanning Hosts

Wget’s recursive retrieval normally refuses to visit hosts different than the one you specified on the command line. This is a reasonable default; without it, every retrieval would have the potential to turn your Wget into a small version of google.

However, visiting different hosts, or host spanning, is sometimes a useful option. Maybe the images are served from a different server. Maybe you’re mirroring a site that consists of pages interlinked between three servers. Maybe the server has two equivalent names, and the HTML pages refer to both interchangeably.

4.2 Types of Files

When downloading material from the web, you will often want to restrict the retrieval to only certain file types. For example, if you are interested in downloading GIFs, you will not be overjoyed to get loads of PostScript documents, and vice versa.

This behavior, too, is considered less-than-desirable, and may change in a future version of Wget.

4.3 Directory-Based Limits

Regardless of other link-following facilities, it is often useful to place the restriction of what files to retrieve based on the directories those files are placed in. There can be many reasons for this—the home pages may be organized in a reasonable directory structure; or some directories may contain useless information, e.g. /cgi-bin or /dev directories.

The simplest, and often very useful way of limiting directories is disallowing retrieval of the links that refer to the hierarchy above than the beginning directory, i.e. disallowing ascent to the parent directory/directories.

You may rest assured that none of the references to /

luzer/my-archive ’, only it handles redirections in a more intelligent fashion.

4.4 Relative Links

These links are not relative:

This option is probably not very useful and might be removed in a future release.

4.5 Following FTP Links

The rules for FTP are somewhat specific, as it is necessary for them to be. FTP links in HTML documents are often included for purposes of reference, and it is often inconvenient to download them by default.

Also note that followed links to FTP directories will not be retrieved recursively further.

5 Time-Stamping

One of the most important aspects of mirroring information from the Internet is updating your archives.

Downloading the whole archive again and again, just to replace a few changed files is expensive, both in terms of wasted bandwidth and money, and the time to do the update. This is why all the mirroring tools offer the option of incremental updating.

Such an updating mechanism means that the remote server is scanned in search of new files. Only those new files will be downloaded in the place of the old ones.

A file is considered new if one of these two conditions are met:

To implement this, the program needs to be aware of the time of last modification of both local and remote files. We call this information the time-stamp of a file.

If the local file does not exist, or the sizes of the files do not match, Wget will download the remote file no matter what the time-stamps say.

5.1 Time-Stamping Usage

The usage of time-stamping is simple. Say you would like to download a file so that it keeps its date of modification.

Several days later, you would like Wget to check if the remote file has changed, and download it if it has.

Wget will ask the server for the last-modified date. If the local file has the same timestamp as the server, or a newer one, the remote file will not be re-fetched. However, if the remote file is more recent, Wget will proceed to fetch it.

The same goes for FTP. For example:

(The quotes around that URL are to prevent the shell from trying to interpret the ‘ * ’.)

If you wished to mirror the GNU archive every week, you would use a command like the following, weekly:

Note that time-stamping will only work for files for which the server gives a timestamp. For HTTP, this depends on getting a Last-Modified header. For FTP, this depends on getting a directory listing with dates in a format that Wget can parse (see FTP Time-Stamping Internals).

5.2 HTTP Time-Stamping Internals

Time-stamping in HTTP is implemented by checking of the Last-Modified header. If you wish to retrieve the file foo.html through HTTP, Wget will check whether foo.html exists locally. If it doesn’t, foo.html will be retrieved unconditionally.

The Last-Modified header is examined to find which file was modified more recently (which makes it “newer”). If the remote file is newer, it will be downloaded; if it is older, Wget will give up. 2

Arguably, HTTP time-stamping should be implemented using the If-Modified-Since request.

5.3 FTP Time-Stamping Internals

In theory, FTP time-stamping works much the same as HTTP, only FTP has no headers—time-stamps must be ferreted out of directory listings.

Assumption that every directory listing is a Unix-style listing may sound extremely constraining, but in practice it is not, as many non-Unix FTP servers use the Unixoid listing format because most (all?) of the clients understand it. Bear in mind that RFC959 defines no standard way to get a file list, let alone the time-stamps. We can only hope that a future standard will define this.

Another non-standard solution includes the use of MDTM command that is supported by some FTP servers (including the popular wu-ftpd ), which returns the exact time of the specified file. Wget may support this command in the future.

6 Startup File

• Wgetrc LocationLocation of various wgetrc files.
• Wgetrc SyntaxSyntax of wgetrc.
• Wgetrc CommandsList of available commands.
• Sample WgetrcA wgetrc example.

6.1 Wgetrc Location

Then it will look for the user’s file. If the environmental variable WGETRC is set, Wget will try to load that file. Failing that, no further attempts will be made.

The fact that user’s settings are loaded after the system-wide ones means that in case of collision user’s wgetrc overrides the system-wide wgetrc (in /usr/local/etc/wgetrc by default). Fascist admins, away!

6.2 Wgetrc Syntax

The syntax of a wgetrc command is simple:

The variable will also be called command. Valid values are different for different commands.

The commands are case-, underscore- and minus-insensitive. Thus ‘ DIr__PrefiX ’, ‘ DIr-PrefiX ’ and ‘ dirprefix ’ are the same. Empty lines, lines beginning with ‘ # ’ and lines containing white-space only are discarded.

6.3 Wgetrc Commands

The complete set of commands is listed below. Legal values are listed after the ‘ = ’. Simple Boolean values can be set or unset using ‘ on ’ and ‘ off ’ or ‘ 1 ’ and ‘ 0 ’.

Some commands take pseudo-arbitrary values. address values can be hostnames or dotted-quad IP addresses. n can be any positive integer, or ‘ inf ’ for infinity, where appropriate. string values can be any non-empty string.

Use up to number backups for a file. Backups are rotated by adding an incremental counter that starts at ‘ 1 ’. The default is ‘ 0 ’.

If set to on, construct the local file name from redirection URLs rather than original URLs.

Specify the number of bytes “contained” in a dot, as seen throughout the retrieval (1024 by default). You can postfix the value with ‘ k ’ or ‘ m ’, representing kilobytes and megabytes, respectively. With dot settings you can tailor the dot retrieval to suit your needs, or you can use the predefined styles (see Download Options).

Specify the number of dots in a single cluster (10 by default).

Specify the number of dots that will be printed in each line throughout the retrieval (50 by default).

This command used to be named passwd prior to Wget 1.10.

Use string as FTP proxy, instead of the one specified in environment.

This command used to be named login prior to Wget 1.10.

Use string as HTTP proxy, instead of the one specified in environment.

When in recursive mode, only HTTPS links are followed (defaults to off).

Use string as HTTPS proxy, instead of the one specified in environment.

Turn reading netrc on or off.

Use string as the comma-separated list of domains to avoid in proxy loading, instead of the one specified in environment.

Specify password string for both FTP and HTTP file retrieval. This command can be overridden using the ‘ ftp_password ’ and ‘ http_password ’ command for FTP and HTTP respectively.

Specify whether the norobots convention is respected by Wget, “on” by default. This switch controls both the /robots.txt and the ‘ nofollow ’ aspect of the spec. See Robot Exclusion, for more details about this. Be sure you know what you are doing before turning this off.

When a DNS name is resolved, show all the IP addresses, not just the first three.

Specify username string for both FTP and HTTP file retrieval. This command can be overridden using the ‘ ftp_user ’ and ‘ http_user ’ command for FTP and HTTP respectively.

6.4 Sample Wgetrc

Note that almost all the lines are commented out. For a command to have any effect, you must remove the ‘ # ’ character at the beginning of its line.

7 Examples

The examples are divided into three sections loosely based on their complexity.

• Simple UsageSimple, basic usage of the program.
• Advanced UsageAdvanced tips.
• Very Advanced UsageThe hairy stuff.

7.1 Simple Usage

7.2 Advanced Usage

You can also combine the two options and make pipelines to retrieve the documents from remote hotlists:

7.3 Very Advanced Usage

Or, with less typing:

8 Various

This chapter contains all the stuff that could not fit anywhere else.

• ProxiesSupport for proxy servers.
• DistributionGetting the latest version.
• Web SiteGNU Wget’s presence on the World Wide Web.
• Mailing ListsWget mailing list for announcements and discussion.
• Internet Relay ChatWget’s presence on IRC.
• Reporting BugsHow and where to report bugs.
• PortabilityThe systems Wget works on.
• SignalsSignal-handling performed by Wget.

8.1 Proxies

Proxies are special-purpose HTTP servers designed to transfer data from remote servers to local clients. One typical use of proxies is lightening network load for users behind a slow connection. This is achieved by channeling all HTTP and FTP requests through the proxy which caches the transferred data. When a cached resource is requested again, proxy will return the data from cache. Another use for proxies is for companies that separate (for security reasons) their internal networks from the rest of Internet. In order to obtain information from the Web, their users connect and retrieve remote data using an authorized proxy.

Wget supports proxies for both HTTP and FTP retrievals. The standard way to specify proxy location, which Wget recognizes, is using the following environment variables:

If set, the http_proxy and https_proxy variables should contain the URLs of the proxies for HTTP and HTTPS connections respectively.

This variable should contain the URL of the proxy for FTP connections. It is quite common that http_proxy and ftp_proxy are set to the same URL.

In addition to the environment variables, proxy location and settings may be specified from within Wget itself.

This option and the corresponding command may be used to suppress the use of proxy, even if the appropriate environment variables are set.

‘ http_proxy = URL ’ ‘ https_proxy = URL ’ ‘ ftp_proxy = URL ’ ‘ no_proxy = string ’

These startup file variables allow you to override the proxy settings specified by the environment.

Some proxy servers require authorization to enable you to use them. The authorization consists of username and password, which must be sent by Wget. As with HTTP authorization, several authentication schemes exist. For proxy authorization only the Basic authentication scheme is currently implemented.

You may specify your username and password either through the proxy URL or through the command-line options. Assuming that the company’s proxy is located at ‘ proxy.company.com ’ at port 8001, a proxy URL location containing authorization data might look like this:

8.2 Distribution

Like all GNU utilities, the latest version of Wget can be found at the master GNU archive site ftp.gnu.org, and its mirrors. For example, Wget 1.21.1-dirty can be found at https://ftp.gnu.org/pub/gnu/wget/wget-1.21.1-dirty.tar.gz

8.3 Web Site

The official web site for GNU Wget is at https//www.gnu.org/software/wget/. However, most useful information resides at “The Wget Wgiki”, http://wget.addictivecode.org/.

8.4 Mailing Lists

Primary List

The primary mailinglist for discussion, bug-reports, or questions about GNU Wget is at bug-wget@gnu.org. To subscribe, send an email to bug-wget-join@gnu.org, or visit https://lists.gnu.org/mailman/listinfo/bug-wget.

You do not need to subscribe to send a message to the list; however, please note that unsubscribed messages are moderated, and may take a while before they hit the list—usually around a day. If you want your message to show up immediately, please subscribe to the list before posting. Archives for the list may be found at https://lists.gnu.org/archive/html/bug-wget/.

An NNTP/Usenettish gateway is also available via Gmane. You can see the Gmane archives at http://news.gmane.org/gmane.comp.web.wget.general. Note that the Gmane archives conveniently include messages from both the current list, and the previous one. Messages also show up in the Gmane archives sooner than they do at https://lists.gnu.org.

Obsolete Lists

Previously, the mailing list wget@sunsite.dk was used as the main discussion list, and another list, wget-patches@sunsite.dk was used for submitting and discussing patches to GNU Wget.

Messages from wget@sunsite.dk are archived at

Messages from wget-patches@sunsite.dk are archived at

8.5 Internet Relay Chat

8.6 Reporting Bugs

You are welcome to submit bug reports via the GNU Wget bug tracker (see https://savannah.gnu.org/bugs/?func=additem&group=wget) or to our mailing list bug-wget@gnu.org.

Before actually submitting a bug report, please try to follow a few simple guidelines.

8.7 Portability

Like all GNU software, Wget works on the GNU system. However, since it uses GNU Autoconf for building and configuring, and mostly avoids using “special” features of any particular Unix, it should compile (and work) on all common Unix flavors.

Various Wget versions have been compiled and tested under many kinds of Unix systems, including GNU/Linux, Solaris, SunOS 4.x, Mac OS X, OSF (aka Digital Unix or Tru64), Ultrix, *BSD, IRIX, AIX, and others. Some of those systems are no longer in widespread use and may not be able to support recent versions of Wget. If Wget fails to compile on your system, we would like to know about it.

Thanks to kind contributors, this version of Wget compiles and works on 32-bit Microsoft Windows platforms. It has been compiled successfully using MS Visual C++ 6.0, Watcom, Borland C, and GCC compilers. Naturally, it is crippled of some features available on Unix, but it should work as a substitute for people stuck with Windows. Note that Windows-specific portions of Wget are not guaranteed to be supported in the future, although this has been the case in practice for many years now. All questions and problems in Windows usage should be reported to Wget mailing list at wget@sunsite.dk where the volunteers who maintain the Windows-related features might look at them.

Support for building on MS-DOS via DJGPP has been contributed by Gisle Vanem; a port to VMS is maintained by Steven Schweda, and is available at https://antinode.info/dec/sw/wget.html.

8.8 Signals

9 Appendices

This chapter contains some references I consider useful.

• Robot ExclusionWget’s support for RES.
• Security ConsiderationsSecurity with Wget.
• ContributorsPeople who helped.

9.1 Robot Exclusion

To avoid this kind of accident, as well as to preserve privacy for documents that need to be protected from well-behaved robots, the concept of robot exclusion was invented. The idea is that the server administrators and document authors can specify which portions of the site they wish to protect from robots and those they will permit access.

The most popular mechanism, and the de facto standard supported by all the major robots, is the “Robots Exclusion Standard” (RES) written by Martijn Koster et al. in 1994. It specifies the format of a text file containing directives that instruct the robots which URL paths to avoid. To be found by the robots, the specifications must be placed in /robots.txt in the server root, which the robots are expected to download and parse.

Although Wget is not a web robot in the strictest sense of the word, it can download large parts of the site without the user’s intervention to download an individual page. Because of that, Wget honors RES when downloading recursively. For instance, when you issue:

First the index of ‘ www.example.com ’ will be downloaded. If Wget finds that it wants to download more documents from that server, it will request ‘ http://www.example.com/robots.txt ’ and, if found, use it for further downloads. robots.txt is loaded only once per each server.

Until version 1.8, Wget supported the first version of the standard, written by Martijn Koster in 1994 and available at http://www.robotstxt.org/orig.html. As of version 1.8, Wget has supported the additional directives specified in the internet draft ‘ ’ titled “A Method for Web Robots Control”. The draft, which has as far as I know never made to an RFC, is available at http://www.robotstxt.org/norobots-rfc.txt.

This manual no longer includes the text of the Robot Exclusion Standard.

The second, less known mechanism, enables the author of an individual document to specify whether they want the links from the file to be followed by a robot. This is achieved using the META tag, like this:

This is explained in some detail at http://www.robotstxt.org/meta.html. Wget supports this method of robot exclusion in addition to the usual /robots.txt exclusion.

9.2 Security Considerations

When using Wget, you must be aware that it sends unencrypted passwords through the network, which may present a security problem. Here are the main issues, and some solutions.

9.3 Contributors

GNU Wget was written by Hrvoje Nikšić hniksic@xemacs.org,

However, the development of Wget could never have gone as far as it has, were it not for the help of many people, either with bug reports, feature proposals, patches, or letters saying “Thanks!”.

Special thanks goes to the following people (no particular order):

The following people have provided patches, bug/build reports, useful suggestions, beta testing services, fan mail and all the other things that make maintenance so much fun:

Tim Adam, Adrian Aichner, Martin Baehr, Dieter Baron, Roger Beeman, Dan Berger, T. Bharath, Christian Biere, Paul Bludov, Daniel Bodea, Mark Boyns, John Burden, Julien Buty, Wanderlei Cavassin, Gilles Cedoc, Tim Charron, Noel Cragg, Kristijan Čonkaš, John Daily, Andreas Damm, Ahmon Dancy, Andrew Davison, Bertrand Demiddelaer, Alexander Dergachev, Andrew Deryabin, Ulrich Drepper, Marc Duponcheel, Damir Džeko, Alan Eldridge, Hans-Andreas Engel, Aleksandar Erkalović, Andy Eskilsson, João Ferreira, Christian Fraenkel, David Fritz, Mike Frysinger, Charles C. Fu, FUJISHIMA Satsuki, Masashi Fujita, Howard Gayle, Marcel Gerrits, Lemble Gregory, Hans Grobler, Alain Guibert, Mathieu Guillaume, Aaron Hawley, Jochen Hein, Karl Heuer, Madhusudan Hosaagrahara, HIROSE Masaaki, Ulf Harnhammar, Gregor Hoffleit, Erik Magnus Hulthen, Richard Huveneers, Jonas Jensen, Larry Jones, Simon Josefsson, Mario Jurić, Hack Kampbjørn, Const Kaplinsky, Goran Kezunović, Igor Khristophorov, Robert Kleine, KOJIMA Haime, Fila Kolodny, Alexander Kourakos, Martin Kraemer, Sami Krank, Jay Krell, Σίμος Ξενιτέλλης (Simos KSenitellis), Christian Lackas, Hrvoje Lacko, Daniel S. Lewart, Nicolás Lichtmeier, Dave Love, Alexander V. Lukyanov, Thomas Lußnig, Andre Majorel, Aurelien Marchand, Matthew J. Mellon, Jordan Mendelson, Ted Mielczarek, Robert Millan, Lin Zhe Min, Jan Minar, Tim Mooney, Keith Moore, Adam D. Moss, Simon Munton, Charlie Negyesi, R. K. Owen, Jim Paris, Kenny Parnell, Leonid Petrov, Simone Piunno, Andrew Pollock, Steve Pothier, Jan Přikryl, Marin Purgar, Csaba Ráduly, Keith Refson, Bill Richardson, Tyler Riddle, Tobias Ringstrom, Jochen Roderburg, Juan José Rodríguez, Maciej W. Rozycki, Edward J. Sabol, Heinz Salzmann, Robert Schmidt, Nicolas Schodet, Benno Schulenberg, Andreas Schwab, Steven M. Schweda, Chris Seawood, Pranab Shenoy, Dennis Smit, Toomas Soome, Tage Stabell-Kulo, Philip Stadermann, Daniel Stenberg, Sven Sternberger, Markus Strasser, John Summerfield, Szakacsits Szabolcs, Mike Thomas, Philipp Thomas, Mauro Tortonesi, Dave Turner, Gisle Vanem, Rabin Vincent, Russell Vincent, Željko Vrba, Charles G Waldman, Douglas E. Wegscheid, Ralf Wildenhues, Joshua David Williams, Benjamin Wolsey, Saint Xavier, YAMAZAKI Makoto, Jasmin Zainul, Bojan Ždrnja, Kristijan Zimmer, Xin Zou.

Apologies to all who I accidentally left out, and many thanks to all the subscribers of the Wget mailing list.

Appendix A Copying this manual

A.1 GNU Free Documentation License

The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

The “publisher” means any person or entity that distributes copies of the Document to the public.

A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies.

If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.

“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

“Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.

An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

Concept Index

Jump to:# .
A B C D E F G H I K L M N O P Q R S T U V W X
Index EntrySection
#
#wget:Internet Relay Chat
.
.css extension:HTTP Options
.html extension:HTTP Options
.listing files, removing:FTP Options
.netrc:Startup File
.wgetrc:Startup File
A
accept directories:Directory-Based Limits
accept suffixes:Types of Files
accept wildcards:Types of Files
append to log:Logging and Input File Options
arguments:Invoking
authentication:Download Options
authentication:HTTP Options
authentication:HTTP Options
authentication credentials:Download Options
B
backing up converted files:Recursive Retrieval Options
backing up files:Download Options
bandwidth, limit:Download Options
base for relative links in input file:Logging and Input File Options
bind address:Download Options
bind DNS address:Download Options
bug reports:Reporting Bugs
bugs:Reporting Bugs
C
cache:HTTP Options
caching of DNS lookups:Download Options
case fold:Recursive Accept/Reject Options
client DNS address:Download Options
client IP address:Download Options
clobbering, file:Download Options
command line:Invoking
comments, HTML:Recursive Retrieval Options
connect timeout:Download Options
Content On Error:HTTP Options
Content-Disposition:HTTP Options
Content-Encoding, choose:HTTP Options
Content-Length, ignore:HTTP Options
continue retrieval:Download Options
continue retrieval:Download Options
contributors:Contributors
conversion of links:Recursive Retrieval Options
cookies:HTTP Options
cookies, loading:HTTP Options
cookies, saving:HTTP Options
cookies, session:HTTP Options
cut directories:Directory Options
D
debug:Logging and Input File Options
default page name:HTTP Options
delete after retrieval:Recursive Retrieval Options
directories:Directory-Based Limits
directories, exclude:Directory-Based Limits
directories, include:Directory-Based Limits
directory limits:Directory-Based Limits
directory prefix:Directory Options
DNS cache:Download Options
DNS IP address, client, DNS:Download Options
DNS IP address, client, DNS:Download Options
DNS server:Download Options
DNS timeout:Download Options
dot style:Download Options
downloading multiple times:Download Options
E
EGD:HTTPS (SSL/TLS) Options
entropy, specifying source of:HTTPS (SSL/TLS) Options
examples:Examples
exclude directories:Directory-Based Limits
execute wgetrc command:Basic Startup Options
F
FDL, GNU Free Documentation License:GNU Free Documentation License
features:Overview
file names, restrict:Download Options
file permissions:FTP Options
filling proxy cache:Recursive Retrieval Options
follow FTP links:Recursive Accept/Reject Options
following ftp links:FTP Links
following links:Following Links
force html:Logging and Input File Options
ftp authentication:FTP Options
ftp password:FTP Options
ftp time-stamping:FTP Time-Stamping Internals
ftp user:FTP Options
G
globbing, toggle:FTP Options
H
hangup:Signals
header, add:HTTP Options
hosts, spanning:Spanning Hosts
HSTS:HTTPS (SSL/TLS) Options
HTML comments:Recursive Retrieval Options
http password:HTTP Options
http referer:HTTP Options
http time-stamping:HTTP Time-Stamping Internals
http user:HTTP Options
I
idn support:Download Options
ignore case:Recursive Accept/Reject Options
ignore length:HTTP Options
include directories:Directory-Based Limits
incomplete downloads:Download Options
incomplete downloads:Download Options
incremental updating:Time-Stamping
index.html:HTTP Options
input-file:Logging and Input File Options
input-metalink:Logging and Input File Options
Internet Relay Chat:Internet Relay Chat
invoking:Invoking
IP address, client:Download Options
IPv6:Download Options
IRC:Internet Relay Chat
iri support:Download Options
K
Keep-Alive, turning off:HTTP Options
keep-badhash:Logging and Input File Options
L
latest version:Distribution
limit bandwidth:Download Options
link conversion:Recursive Retrieval Options
links:Following Links
list:Mailing Lists
loading cookies:HTTP Options
local encoding:Download Options
location of wgetrc:Wgetrc Location
log file:Logging and Input File Options
M
mailing list:Mailing Lists
metalink-index:Logging and Input File Options
metalink-over-http:Logging and Input File Options
mirroring:Very Advanced Usage
N
no parent:Directory-Based Limits
no-clobber:Download Options
nohup:Invoking
number of tries:Download Options
O
offset:Download Options
operating systems:Portability
option syntax:Option Syntax
Other HTTP Methods:HTTP Options
output file:Logging and Input File Options
overview:Overview
P
page requisites:Recursive Retrieval Options
passive ftp:FTP Options
password:Download Options
pause:Download Options
Persistent Connections, disabling:HTTP Options
portability:Portability
POST:HTTP Options
preferred-location:Logging and Input File Options
progress indicator:Download Options
proxies:Proxies
proxy:Download Options
proxy:HTTP Options
proxy authentication:HTTP Options
proxy filling:Recursive Retrieval Options
proxy password:HTTP Options
proxy user:HTTP Options
Q
quiet:Logging and Input File Options
quota:Download Options
R
random wait:Download Options
randomness, specifying source of:HTTPS (SSL/TLS) Options
rate, limit:Download Options
read timeout:Download Options
recursion:Recursive Download
recursive download:Recursive Download
redirect:HTTP Options
redirecting output:Advanced Usage
referer, http:HTTP Options
reject directories:Directory-Based Limits
reject suffixes:Types of Files
reject wildcards:Types of Files
relative links:Relative Links
remote encoding:Download Options
reporting bugs:Reporting Bugs
required images, downloading:Recursive Retrieval Options
resume download:Download Options
resume download:Download Options
retries:Download Options
retries, waiting between:Download Options
retrieving:Recursive Download
robot exclusion:Robot Exclusion
robots.txt:Robot Exclusion
S
sample wgetrc:Sample Wgetrc
saving cookies:HTTP Options
security:Security Considerations
server maintenance:Robot Exclusion
server response, print:Download Options
server response, save:HTTP Options
session cookies:HTTP Options
signal handling:Signals
spanning hosts:Spanning Hosts
specify config:Logging and Input File Options
spider:Download Options
SSL:HTTPS (SSL/TLS) Options
SSL certificate:HTTPS (SSL/TLS) Options
SSL certificate authority:HTTPS (SSL/TLS) Options
SSL certificate type, specify:HTTPS (SSL/TLS) Options
SSL certificate, check:HTTPS (SSL/TLS) Options
SSL CRL, certificate revocation list:HTTPS (SSL/TLS) Options
SSL protocol, choose:HTTPS (SSL/TLS) Options
SSL Public Key Pin:HTTPS (SSL/TLS) Options
start position:Download Options
startup:Startup File
startup file:Startup File
suffixes, accept:Types of Files
suffixes, reject:Types of Files
symbolic links, retrieving:FTP Options
syntax of options:Option Syntax
syntax of wgetrc:Wgetrc Syntax
T
tag-based recursive pruning:Recursive Accept/Reject Options
time-stamping:Time-Stamping
time-stamping usage:Time-Stamping Usage
timeout:Download Options
timeout, connect:Download Options
timeout, DNS:Download Options
timeout, read:Download Options
timestamping:Time-Stamping
tries:Download Options
Trust server names:HTTP Options
types of files:Types of Files
U
unlink:Download Options
updating the archives:Time-Stamping
URL:URL Format
URL syntax:URL Format
usage, time-stamping:Time-Stamping Usage
user:Download Options
user-agent:HTTP Options
V
various:Various
verbose:Logging and Input File Options
W
wait:Download Options
wait, random:Download Options
waiting between retries:Download Options
WARC:HTTPS (SSL/TLS) Options
web site:Web Site
Wget as spider:Download Options
wgetrc:Startup File
wgetrc commands:Wgetrc Commands
wgetrc location:Wgetrc Location
wgetrc syntax:Wgetrc Syntax
wildcards, accept:Types of Files
wildcards, reject:Types of Files
Windows file names:Download Options
X
xattr:Logging and Input File Options
Jump to:# .
A B C D E F G H I K L M N O P Q R S T U V W X

Table of Contents

Footnotes

As an additional check, Wget will look at the Content-Length header, and compare the sizes; if they are not the same, the remote file will be downloaded no matter what the time-stamp says.

Linux wget Command Guide [With Examples]

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

If you followed our Magic Mirror tutorial, you’d see the wget command was used to download some files.

This tutorial explains how to use wget, a command-line tool for downloading (getting) files from the web, be it via HTTP, HTTPS, FTP, or FTPS.

Use it to download files from the internet from the Linux shell, call it from Bash scripts – it’s simple and versatile and doesn’t require user interference once started so that it can run in the background.

Syntax

Here are the wget options, straight from the docs:

Examples

Download a File from an HTTPS Server

Download a single file, basic usage:

Continue Downloading a File

If a download only partially completed, continue/resume downloading it with the -c option:

Download From a List of Files, Appending to Log

If you have a text file containing a list of URLs to download, you can pass it directly to wget and write a log of the results for later inspection:

Download a File, Retry 5 Times, Quietly

Retry downloading a file and don’t’ print progress to the terminal:

Download From a List of Files, Waiting 6 Seconds Between Each Download, with a 12 Second Timeout

Wait between downloads to reduce server load, and abort if the server fails to respond within 12 seconds:

Download a File from an FTPS Server which Requires a Username and Password

Download from an FTPS server with the username bob and the password boat:

Download a File with a POST Request

Make an HTTP POST request instead of the default GET request, and send data. A blank string can be sent with –post-data:

In this example, we’re sending two pieces of POST data – postcode and country.

Download Directory Recursively via FTP with a Depth Limit

Downloading recursively will download the contents of a folder and the contents of the folders in that folder. A depth limit of 3 is defined in this example – meaning that if a folder is nested within 3 other folders, it won’t be downloaded:

Downloading a Whole Directory including ALL Contents via FTP

Cloning a Whole Web Page Using Wget

If you want to try and grab a whole webpage – including all images, styles, and scripts, you can use

Your success will vary – some modern web pages don’t really work well when ripped out of their native habitat.

How to Install and Use Wget on Linux

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Wget is a non-interactive network download utility for the Linux command line interface. It’s is used for downloading or retrieving files from web servers or FTP servers. Wget can be installed on most modern operating systems, including Windows, Linux, and macOS.

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

The Wget command comes with several options that allow you to download multiple files, download in the background, mirror a website, resume downloads, limit the bandwidth, download recursively, and lots more. It supports HTTP, HTTPS, and the FTP protocols and also retrieval through HTTP proxies.

In this tutorial, we will show you how to install and use Wget command with some examples on how to use Wget.

Table of Contents

Requirements

Connect to Your Server

Before starting, you need to connect to your server via SSH as the root user or as any other user with sudo privileges.

To connect to your server as the root user, use the following command:

Make sure to replace IP_ADDRESS and PORT_NUMBER with your actual server IP address and SSH port number. The default port number is 22, so try that one first if you’re not sure.

Once logged in, make sure that your server is up-to-date by running the following commands:

Now that everything is up to date, we can install Wget and see how to use it.

Install Wget

By default, the Wget package comes pre-installed in most Linux operating systems. If not installed, you can install it using either the APT or YUM command-line utility (depending on your Linux distribution).

For RHEL/CentOS/Fedora, install Wget by running the following command:

For Debian/Ubuntu, install Wget by running the following command:

Once installed, you can verify the installed version of Wget command using the following command:

Download a Single File

You can use the Wget command without any options specified to download a file from the specified URL to your current working directory.

For example, download this Drupal install file using the Wget command, as shown below:

You should see the following screen:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

In the above screen, you can see the progress bar, downloaded file size and download speed.

Download Multiple Files

The Wget command also allows you to download multiple files by specifying multiple URLs.

For example, the following command will download Drupal and WordPress files:

You should see the following screen:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

First, create a text file using the following command:

Add all the URL’s that you want to download:

Save and close the file.

You should see the following screen:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Download Files and Save them with a Different Name

You should see the following screen:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Resume an Incomplete Download

Press CTRL + C to stop the downloading process:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Now, run the above command again:

This will download the file where it was left off, as shown below:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Download a File in the Background

This command will save the downloading progress log in the wget-log file in the current directory.

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

You can check it with the following command:

Limit the Download Speed

For example, download the WordPress file and limit the download speed to 256KBps, as shown below:

You should see the following screen:

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

This option is very useful if you don’t want Wget to use all of your available bandwidth.

If you want to download a file from a password-protected FTP server, use the following command:

Hopefully you now have a clearer view of what Wget can do for you. It’s a useful application whose features are rarely ever used outside of the most basic function.

Wget how to use. Смотреть фото Wget how to use. Смотреть картинку Wget how to use. Картинка про Wget how to use. Фото Wget how to use

Using Wget on your server is easy, but you’re probably using it to download and install some software on your server. Our managed Linux VPS hosting gives you the freedom to never have to download and install programs ever again. Just ask our admins to install and configure any software that you need, and they’ll have it handled immediately. It’s completely free and they’re available to help you 24/7. They also handle maintenance and optimization to keep your server running at its fastest for a long time.

If this tutorial gave you the help you needed for installing Wget, maybe consider sharing it through the use of our share shortcuts. You can also leave any questions or suggestions in our comments section below. Thank you.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *