1uri(7) Miscellaneous Information Manual uri(7)
2
3
4
6 uri, url, urn - uniform resource identifier (URI), including a URL or
7 URN
8
10 URI = [ absoluteURI | relativeURI ] [ "#" fragment ]
11
12 absoluteURI = scheme ":" ( hierarchical_part | opaque_part )
13
14 relativeURI = ( net_path | absolute_path | relative_path ) [ "?" query ]
15
16 scheme = "http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" |
17 "file" | "man" | "info" | "whatis" | "ldap" | "wais" | ...
18
19 hierarchical_part = ( net_path | absolute_path ) [ "?" query ]
20
21 net_path = "//" authority [ absolute_path ]
22
23 absolute_path = "/" path_segments
24
25 relative_path = relative_segment [ absolute_path ]
26
28 A Uniform Resource Identifier (URI) is a short string of characters
29 identifying an abstract or physical resource (for example, a web page).
30 A Uniform Resource Locator (URL) is a URI that identifies a resource
31 through its primary access mechanism (e.g., its network "location"),
32 rather than by name or some other attribute of that resource. A Uni‐
33 form Resource Name (URN) is a URI that must remain globally unique and
34 persistent even when the resource ceases to exist or becomes unavail‐
35 able.
36
37 URIs are the standard way to name hypertext link destinations for tools
38 such as web browsers. The string "http://www.kernel.org" is a URL (and
39 thus it is also a URI). Many people use the term URL loosely as a syn‐
40 onym for URI (though technically URLs are a subset of URIs).
41
42 URIs can be absolute or relative. An absolute identifier refers to a
43 resource independent of context, while a relative identifier refers to
44 a resource by describing the difference from the current context.
45 Within a relative path reference, the complete path segments "." and
46 ".." have special meanings: "the current hierarchy level" and "the
47 level above this hierarchy level", respectively, just like they do in
48 UNIX-like systems. A path segment which contains a colon character
49 can't be used as the first segment of a relative URI path (e.g.,
50 "this:that"), because it would be mistaken for a scheme name; precede
51 such segments with ./ (e.g., "./this:that"). Note that descendants of
52 MS-DOS (e.g., Microsoft Windows) replace devicename colons with the
53 vertical bar ("|") in URIs, so "C:" becomes "C|".
54
55 A fragment identifier, if included, refers to a particular named por‐
56 tion (fragment) of a resource; text after a '#' identifies the frag‐
57 ment. A URI beginning with '#' refers to that fragment in the current
58 resource.
59
60 Usage
61 There are many different URI schemes, each with specific additional
62 rules and meanings, but they are intentionally made to be as similar as
63 possible. For example, many URL schemes permit the authority to be the
64 following format, called here an ip_server (square brackets show what's
65 optional):
66
67 ip_server = [user [ : password ] @ ] host [ : port]
68
69 This format allows you to optionally insert a username, a user plus
70 password, and/or a port number. The host is the name of the host com‐
71 puter, either its name as determined by DNS or an IP address (numbers
72 separated by periods). Thus the URI <http://fred:fredpassword@exam‐
73 ple.com:8080/> logs into a web server on host example.com as fred (us‐
74 ing fredpassword) using port 8080. Avoid including a password in a URI
75 if possible because of the many security risks of having a password
76 written down. If the URL supplies a username but no password, and the
77 remote server requests a password, the program interpreting the URL
78 should request one from the user.
79
80 Here are some of the most common schemes in use on UNIX-like systems
81 that are understood by many tools. Note that many tools using URIs
82 also have internal schemes or specialized schemes; see those tools'
83 documentation for information on those schemes.
84
85 http - Web (HTTP) server
86
87 http://ip_server/path
88 http://ip_server/path?query
89
90 This is a URL accessing a web (HTTP) server. The default port is 80.
91 If the path refers to a directory, the web server will choose what to
92 return; usually if there is a file named "index.html" or "index.htm"
93 its content is returned, otherwise, a list of the files in the current
94 directory (with appropriate links) is generated and returned. An exam‐
95 ple is <http://lwn.net>.
96
97 A query can be given in the archaic "isindex" format, consisting of a
98 word or phrase and not including an equal sign (=). A query can also
99 be in the longer "GET" format, which has one or more query entries of
100 the form key=value separated by the ampersand character (&). Note that
101 key can be repeated more than once, though it's up to the web server
102 and its application programs to determine if there's any meaning to
103 that. There is an unfortunate interaction with HTML/XML/SGML and the
104 GET query format; when such URIs with more than one key are embedded in
105 SGML/XML documents (including HTML), the ampersand (&) has to be
106 rewritten as &. Note that not all queries use this format; larger
107 forms may be too long to store as a URI, so they use a different inter‐
108 action mechanism (called POST) which does not include the data in the
109 URI. See the Common Gateway Interface specification at
110 ⟨http://www.w3.org/CGI⟩ for more information.
111
112 ftp - File Transfer Protocol (FTP)
113
114 ftp://ip_server/path
115
116 This is a URL accessing a file through the file transfer protocol
117 (FTP). The default port (for control) is 21. If no username is in‐
118 cluded, the username "anonymous" is supplied, and in that case many
119 clients provide as the password the requestor's Internet email address.
120 An example is <ftp://ftp.is.co.za/rfc/rfc1808.txt>.
121
122 gopher - Gopher server
123
124 gopher://ip_server/gophertype selector
125 gopher://ip_server/gophertype selector%09search
126 gopher://ip_server/gophertype selector%09search%09gopher+_string
127
128 The default gopher port is 70. gophertype is a single-character field
129 to denote the Gopher type of the resource to which the URL refers. The
130 entire path may also be empty, in which case the delimiting "/" is also
131 optional and the gophertype defaults to "1".
132
133 selector is the Gopher selector string. In the Gopher protocol, Gopher
134 selector strings are a sequence of octets which may contain any octets
135 except 09 hexadecimal (US-ASCII HT or tab), 0A hexadecimal (US-ASCII
136 character LF), and 0D (US-ASCII character CR).
137
138 mailto - Email address
139
140 mailto:email-address
141
142 This is an email address, usually of the form name@hostname. See
143 mailaddr(7) for more information on the correct format of an email ad‐
144 dress. Note that any % character must be rewritten as %25. An example
145 is <mailto:dwheeler@dwheeler.com>.
146
147 news - Newsgroup or News message
148
149 news:newsgroup-name
150 news:message-id
151
152 A newsgroup-name is a period-delimited hierarchical name, such as
153 "comp.infosystems.www.misc". If <newsgroup-name> is "*" (as in
154 <news:*>), it is used to refer to "all available news groups". An ex‐
155 ample is <news:comp.lang.ada>.
156
157 A message-id corresponds to the Message-ID of IETF RFC 1036,
158 ⟨http://www.ietf.org/rfc/rfc1036.txt⟩ without the enclosing "<" and
159 ">"; it takes the form unique@full_domain_name. A message identifier
160 may be distinguished from a news group name by the presence of the "@"
161 character.
162
163 telnet - Telnet login
164
165 telnet://ip_server/
166
167 The Telnet URL scheme is used to designate interactive text services
168 that may be accessed by the Telnet protocol. The final "/" character
169 may be omitted. The default port is 23. An example is <tel‐
170 net://melvyl.ucop.edu/>.
171
172 file - Normal file
173
174 file://ip_server/path_segments
175 file:path_segments
176
177 This represents a file or directory accessible locally. As a special
178 case, ip_server can be the string "localhost" or the empty string; this
179 is interpreted as "the machine from which the URL is being inter‐
180 preted". If the path is to a directory, the viewer should display the
181 directory's contents with links to each containee; not all viewers cur‐
182 rently do this. KDE supports generated files through the URL
183 <file:/cgi-bin>. If the given file isn't found, browser writers may
184 want to try to expand the filename via filename globbing (see glob(7)
185 and glob(3)).
186
187 The second format (e.g., <file:/etc/passwd>) is a correct format for
188 referring to a local file. However, older standards did not permit
189 this format, and some programs don't recognize this as a URI. A more
190 portable syntax is to use an empty string as the server name, for exam‐
191 ple, <file:///etc/passwd>; this form does the same thing and is easily
192 recognized by pattern matchers and older programs as a URI. Note that
193 if you really mean to say "start from the current location", don't
194 specify the scheme at all; use a relative address like <../test.txt>,
195 which has the side-effect of being scheme-independent. An example of
196 this scheme is <file:///etc/passwd>.
197
198 man - Man page documentation
199
200 man:command-name
201 man:command-name(section)
202
203 This refers to local online manual (man) reference pages. The command
204 name can optionally be followed by a parenthesis and section number;
205 see man(7) for more information on the meaning of the section numbers.
206 This URI scheme is unique to UNIX-like systems (such as Linux) and is
207 not currently registered by the IETF. An example is <man:ls(1)>.
208
209 info - Info page documentation
210
211 info:virtual-filename
212 info:virtual-filename#nodename
213 info:(virtual-filename)
214 info:(virtual-filename)nodename
215
216 This scheme refers to online info reference pages (generated from tex‐
217 info files), a documentation format used by programs such as the GNU
218 tools. This URI scheme is unique to UNIX-like systems (such as Linux)
219 and is not currently registered by the IETF. As of this writing, GNOME
220 and KDE differ in their URI syntax and do not accept the other's syn‐
221 tax. The first two formats are the GNOME format; in nodenames all spa‐
222 ces are written as underscores. The second two formats are the KDE
223 format; spaces in nodenames must be written as spaces, even though this
224 is forbidden by the URI standards. It's hoped that in the future most
225 tools will understand all of these formats and will always accept un‐
226 derscores for spaces in nodenames. In both GNOME and KDE, if the form
227 without the nodename is used the nodename is assumed to be "Top". Ex‐
228 amples of the GNOME format are <info:gcc> and <info:gcc#G++_and_GCC>.
229 Examples of the KDE format are <info:(gcc)> and <info:(gcc)G++ and
230 GCC>.
231
232 whatis - Documentation search
233
234 whatis:string
235
236 This scheme searches the database of short (one-line) descriptions of
237 commands and returns a list of descriptions containing that string.
238 Only complete word matches are returned. See whatis(1). This URI
239 scheme is unique to UNIX-like systems (such as Linux) and is not cur‐
240 rently registered by the IETF.
241
242 ghelp - GNOME help documentation
243
244 ghelp:name-of-application
245
246 This loads GNOME help for the given application. Note that not much
247 documentation currently exists in this format.
248
249 ldap - Lightweight Directory Access Protocol
250
251 ldap://hostport
252 ldap://hostport/
253 ldap://hostport/dn
254 ldap://hostport/dn?attributes
255 ldap://hostport/dn?attributes?scope
256 ldap://hostport/dn?attributes?scope?filter
257 ldap://hostport/dn?attributes?scope?filter?extensions
258
259 This scheme supports queries to the Lightweight Directory Access Proto‐
260 col (LDAP), a protocol for querying a set of servers for hierarchically
261 organized information (such as people and computing resources). See
262 RFC 2255 ⟨http://www.ietf.org/rfc/rfc2255.txt⟩ for more information on
263 the LDAP URL scheme. The components of this URL are:
264
265 hostport
266 the LDAP server to query, written as a hostname optionally fol‐
267 lowed by a colon and the port number. The default LDAP port is
268 TCP port 389. If empty, the client determines which the LDAP
269 server to use.
270
271 dn the LDAP Distinguished Name, which identifies the base object of
272 the LDAP search (see RFC 2253 ⟨http://www.ietf.org/rfc
273 /rfc2253.txt⟩ section 3).
274
275 attributes
276 a comma-separated list of attributes to be returned; see
277 RFC 2251 section 4.1.5. If omitted, all attributes should be
278 returned.
279
280 scope specifies the scope of the search, which can be one of "base"
281 (for a base object search), "one" (for a one-level search), or
282 "sub" (for a subtree search). If scope is omitted, "base" is
283 assumed.
284
285 filter specifies the search filter (subset of entries to return). If
286 omitted, all entries should be returned. See RFC 2254
287 ⟨http://www.ietf.org/rfc/rfc2254.txt⟩ section 4.
288
289 extensions
290 a comma-separated list of type=value pairs, where the =value
291 portion may be omitted for options not requiring it. An exten‐
292 sion prefixed with a '!' is critical (must be supported to be
293 valid), otherwise it is noncritical (optional).
294
295 LDAP queries are easiest to explain by example. Here's a query that
296 asks ldap.itd.umich.edu for information about the University of Michi‐
297 gan in the U.S.:
298
299 ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US
300
301 To just get its postal address attribute, request:
302
303 ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress
304
305 To ask a host.com at port 6666 for information about the person with
306 common name (cn) "Babs Jensen" at University of Michigan, request:
307
308 ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)
309
310 wais - Wide Area Information Servers
311
312 wais://hostport/database
313 wais://hostport/database?search
314 wais://hostport/database/wtype/wpath
315
316 This scheme designates a WAIS database, search, or document (see IETF
317 RFC 1625 ⟨http://www.ietf.org/rfc/rfc1625.txt⟩ for more information on
318 WAIS). Hostport is the hostname, optionally followed by a colon and
319 port number (the default port number is 210).
320
321 The first form designates a WAIS database for searching. The second
322 form designates a particular search of the WAIS database database. The
323 third form designates a particular document within a WAIS database to
324 be retrieved. wtype is the WAIS designation of the type of the object
325 and wpath is the WAIS document-id.
326
327 other schemes
328
329 There are many other URI schemes. Most tools that accept URIs support
330 a set of internal URIs (e.g., Mozilla has the about: scheme for inter‐
331 nal information, and the GNOME help browser has the toc: scheme for
332 various starting locations). There are many schemes that have been de‐
333 fined but are not as widely used at the current time (e.g., prospero).
334 The nntp: scheme is deprecated in favor of the news: scheme. URNs are
335 to be supported by the urn: scheme, with a hierarchical name space
336 (e.g., urn:ietf:... would identify IETF documents); at this time URNs
337 are not widely implemented. Not all tools support all schemes.
338
339 Character encoding
340 URIs use a limited number of characters so that they can be typed in
341 and used in a variety of situations.
342
343 The following characters are reserved, that is, they may appear in a
344 URI but their use is limited to their reserved purpose (conflicting
345 data must be escaped before forming the URI):
346
347 ; / ? : @ & = + $ ,
348
349 Unreserved characters may be included in a URI. Unreserved characters
350 include uppercase and lowercase Latin letters, decimal digits, and the
351 following limited set of punctuation marks and symbols:
352
353 - _ . ! ~ * ' ( )
354
355 All other characters must be escaped. An escaped octet is encoded as a
356 character triplet, consisting of the percent character "%" followed by
357 the two hexadecimal digits representing the octet code (you can use up‐
358 percase or lowercase letters for the hexadecimal digits). For example,
359 a blank space must be escaped as "%20", a tab character as "%09", and
360 the "&" as "%26". Because the percent "%" character always has the re‐
361 served purpose of being the escape indicator, it must be escaped as
362 "%25". It is common practice to escape space characters as the plus
363 symbol (+) in query text; this practice isn't uniformly defined in the
364 relevant RFCs (which recommend %20 instead) but any tool accepting URIs
365 with query text should be prepared for them. A URI is always shown in
366 its "escaped" form.
367
368 Unreserved characters can be escaped without changing the semantics of
369 the URI, but this should not be done unless the URI is being used in a
370 context that does not allow the unescaped character to appear. For ex‐
371 ample, "%7e" is sometimes used instead of "~" in an HTTP URL path, but
372 the two are equivalent for an HTTP URL.
373
374 For URIs which must handle characters outside the US ASCII character
375 set, the HTML 4.01 specification (section B.2) and IETF RFC 3986 (last
376 paragraph of section 2.5) recommend the following approach:
377
378 (1) translate the character sequences into UTF-8 (IETF RFC 3629)—see
379 utf-8(7)—and then
380
381 (2) use the URI escaping mechanism, that is, use the %HH encoding for
382 unsafe octets.
383
384 Writing a URI
385 When written, URIs should be placed inside double quotes (e.g.,
386 "http://www.kernel.org"), enclosed in angle brackets (e.g.,
387 <http://lwn.net>), or placed on a line by themselves. A warning for
388 those who use double-quotes: never move extraneous punctuation (such as
389 the period ending a sentence or the comma in a list) inside a URI,
390 since this will change the value of the URI. Instead, use angle brack‐
391 ets instead, or switch to a quoting system that never includes extrane‐
392 ous characters inside quotation marks. This latter system, called the
393 'new' or 'logical' quoting system by "Hart's Rules" and the "Oxford
394 Dictionary for Writers and Editors", is preferred practice in Great
395 Britain and in various European languages. Older documents suggested
396 inserting the prefix "URL:" just before the URI, but this form has
397 never caught on.
398
399 The URI syntax was designed to be unambiguous. However, as URIs have
400 become commonplace, traditional media (television, radio, newspapers,
401 billboards, etc.) have increasingly used abbreviated URI references
402 consisting of only the authority and path portions of the identified
403 resource (e.g., <www.w3.org/Addressing>). Such references are primar‐
404 ily intended for human interpretation rather than machine, with the as‐
405 sumption that context-based heuristics are sufficient to complete the
406 URI (e.g., hostnames beginning with "www" are likely to have a URI pre‐
407 fix of "http://" and hostnames beginning with "ftp" likely to have a
408 prefix of "ftp://"). Many client implementations heuristically resolve
409 these references. Such heuristics may change over time, particularly
410 when new schemes are introduced. Since an abbreviated URI has the same
411 syntax as a relative URL path, abbreviated URI references cannot be
412 used where relative URIs are permitted, and can be used only when there
413 is no defined base (such as in dialog boxes). Don't use abbreviated
414 URIs as hypertext links inside a document; use the standard format as
415 described here.
416
418 (IETF RFC 2396) ⟨http://www.ietf.org/rfc/rfc2396.txt⟩, (HTML 4.0)
419 ⟨http://www.w3.org/TR/REC-html40⟩.
420
422 Any tool accepting URIs (e.g., a web browser) on a Linux system should
423 be able to handle (directly or indirectly) all of the schemes described
424 here, including the man: and info: schemes. Handling them by invoking
425 some other program is fine and in fact encouraged.
426
427 Technically the fragment isn't part of the URI.
428
429 For information on how to embed URIs (including URLs) in a data format,
430 see documentation on that format. HTML uses the format <A HREF="uri">
431 text </A>. Texinfo files use the format @uref{uri}. Man and mdoc have
432 the recently added UR macro, or just include the URI in the text (view‐
433 ers should be able to detect :// as part of a URI).
434
435 The GNOME and KDE desktop environments currently vary in the URIs they
436 accept, in particular in their respective help browsers. To list man
437 pages, GNOME uses <toc:man> while KDE uses <man:(index)>, and to list
438 info pages, GNOME uses <toc:info> while KDE uses <info:(dir)> (the au‐
439 thor of this man page prefers the KDE approach here, though a more reg‐
440 ular format would be even better). In general, KDE uses <file:/cgi-
441 bin/> as a prefix to a set of generated files. KDE prefers documenta‐
442 tion in HTML, accessed via the <file:/cgi-bin/helpindex>. GNOME pre‐
443 fers the ghelp scheme to store and find documentation. Neither browser
444 handles file: references to directories at the time of this writing,
445 making it difficult to refer to an entire directory with a browsable
446 URI. As noted above, these environments differ in how they handle the
447 info: scheme, probably the most important variation. It is expected
448 that GNOME and KDE will converge to common URI formats, and a future
449 version of this man page will describe the converged result. Efforts
450 to aid this convergence are encouraged.
451
452 Security
453 A URI does not in itself pose a security threat. There is no general
454 guarantee that a URL, which at one time located a given resource, will
455 continue to do so. Nor is there any guarantee that a URL will not lo‐
456 cate a different resource at some later point in time; such a guarantee
457 can be obtained only from the person(s) controlling that namespace and
458 the resource in question.
459
460 It is sometimes possible to construct a URL such that an attempt to
461 perform a seemingly harmless operation, such as the retrieval of an en‐
462 tity associated with the resource, will in fact cause a possibly damag‐
463 ing remote operation to occur. The unsafe URL is typically constructed
464 by specifying a port number other than that reserved for the network
465 protocol in question. The client unwittingly contacts a site that is
466 in fact running a different protocol. The content of the URL contains
467 instructions that, when interpreted according to this other protocol,
468 cause an unexpected operation. An example has been the use of a gopher
469 URL to cause an unintended or impersonating message to be sent via a
470 SMTP server.
471
472 Caution should be used when using any URL that specifies a port number
473 other than the default for the protocol, especially when it is a number
474 within the reserved space.
475
476 Care should be taken when a URI contains escaped delimiters for a given
477 protocol (for example, CR and LF characters for telnet protocols) that
478 these are not unescaped before transmission. This might violate the
479 protocol, but avoids the potential for such characters to be used to
480 simulate an extra operation or parameter in that protocol, which might
481 lead to an unexpected and possibly harmful remote operation to be per‐
482 formed.
483
484 It is clearly unwise to use a URI that contains a password which is in‐
485 tended to be secret. In particular, the use of a password within the
486 "userinfo" component of a URI is strongly recommended against except in
487 those rare cases where the "password" parameter is intended to be pub‐
488 lic.
489
491 Documentation may be placed in a variety of locations, so there cur‐
492 rently isn't a good URI scheme for general online documentation in ar‐
493 bitrary formats. References of the form <file:///usr/doc/ZZZ> don't
494 work because different distributions and local installation require‐
495 ments may place the files in different directories (it may be in
496 /usr/doc, or /usr/local/doc, or /usr/share, or somewhere else). Also,
497 the directory ZZZ usually changes when a version changes (though file‐
498 name globbing could partially overcome this). Finally, using the file:
499 scheme doesn't easily support people who dynamically load documentation
500 from the Internet (instead of loading the files onto a local filesys‐
501 tem). A future URI scheme may be added (e.g., "userdoc:") to permit
502 programs to include cross-references to more detailed documentation
503 without having to know the exact location of that documentation. Al‐
504 ternatively, a future version of the filesystem specification may spec‐
505 ify file locations sufficiently so that the file: scheme will be able
506 to locate documentation.
507
508 Many programs and file formats don't include a way to incorporate or
509 implement links using URIs.
510
511 Many programs can't handle all of these different URI formats; there
512 should be a standard mechanism to load an arbitrary URI that automati‐
513 cally detects the users' environment (e.g., text or graphics, desktop
514 environment, local user preferences, and currently executing tools) and
515 invokes the right tool for any URI.
516
518 lynx(1), man2html(1), mailaddr(7), utf-8(7)
519
520 IETF RFC 2255 ⟨http://www.ietf.org/rfc/rfc2255.txt⟩
521
522
523
524Linux man-pages 6.04 2023-03-08 uri(7)