uri(7)

๐Ÿฆ‹ NAME ๐Ÿฆ‹

uri, url, urn โ€” uniform resource identifier (URI), including a URL or URN ๐Ÿ’… (this is uri(7) bestie, in case the header didn't already scream it at you)


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

okay so here's the vibe in literal grammar form:

URI = [ absoluteURI | relativeURI ] [ "#" fragment ]

absoluteURI = scheme ":" ( hierarchical_part | opaque_part )

relativeURI = ( net_path | absolute_path | relative_path ) [ "?" query ]

scheme = "http" | "ftp" | "gopher" | "mailto" | "news" | "telnet" |
         "file" | "ftp" | "man" | "info" | "whatis" | "ldap" | "wais" |
         ...

hierarchical_part = ( net_path | absolute_path ) [ "?" query ]

net_path = "//" authority [ absolute_path ]

absolute_path = "/" path_segments

relative_path = relative_segment [ absolute_path ]

(yes "ftp" really is in that scheme list twice, no I did not do that, it's just Like That ๐Ÿ’€)


โœจ DESCRIPTION โœจ

A Uniform Resource Identifier (URI) is a short string of characters identifying an abstract or physical resource (for example, a web page ๐Ÿ•ธ๏ธ). A Uniform Resource Locator (URL) is a URI that identifies a resource through its primary access mechanism (e.g., its network "location"), rather than by name or some other attribute of that resource. A Uniform Resource Name (URN) is a URI that must remain globally unique and persistent even when the resource ceases to exist or becomes unavailable. ๐Ÿ‘‘ periodt, that's the whole taxonomy.

URIs are the standard way to name hypertext link destinations for tools such as web browsers. The string "http://www.kernel.org" is a URL (and thus it is also a URI). Many people use the term URL loosely as a synonym for URI (though technically URLs are a subset of URIs). so like, yes, when you say "url" but you mean "uri", everyone knows what you mean, it's fine, we're all guilty ๐Ÿ™ˆ

URIs can be absolute or relative. An absolute identifier refers to a resource independent of context, while a relative identifier refers to a resource by describing the difference from the current context. Within a relative path reference, the complete path segments "." and ".." have special meanings: "the current hierarchy level" and "the level above this hierarchy level", respectively, just like they do in UNIX-like systems. ๐ŸŒ€

A path segment which contains a colon character can't be used as the first segment of a relative URI path (e.g., "this:that"), because it would be mistaken for a scheme name; precede such segments with ./ (e.g., "./this:that"). Bestie I know, it's giving "why is this my problem", but it literally is. ๐Ÿ’…

Note that descendants of MS-DOS (e.g., Microsoft Windows) replace devicename colons with the vertical bar ("|") in URIs, so "C:" becomes "C|".

A fragment identifier, if included, refers to a particular named portion (fragment) of a resource; text after a '#' identifies the fragment. A URI beginning with '#' refers to that fragment in the current resource. ๐ŸŽ€


๐ŸŒธ Usage ๐ŸŒธ

There are so many different URI schemes, each with specific additional rules and meanings, but they are intentionally made to be as similar as possible. For example, many URL schemes permit the authority to be the following format, called here an ip_server (square brackets show what's optional):

ip_server = [user [ : password ] @ ] host [ : port]

This format allows you to optionally insert a username, a user plus password, and/or a port number. The host is the name of the host computer, either its name as determined by DNS or an IP address (numbers separated by periods). Thus the URI <http://fred:fredpassword@example.com:8080/> logs into a web server on host example.com as fred (using fredpassword) using port 8080. ๐Ÿ”‘

Avoid including a password in a URI if possible because of the many security risks of having a password written down. Like, fr fr, don't do it. ๐Ÿ˜ญ

If the URL supplies a username but no password, and the remote server requests a password, the program interpreting the URL should request one from the user.

Here are some of the most common schemes in use on UNIX-like systems that are understood by many tools. Note that many tools using URIs also have internal schemes or specialized schemes; see those tools' documentation for information on those schemes. ๐Ÿ‘€


๐Ÿ”ฅ http โ€” Web (HTTP) server ๐Ÿ”ฅ

http://ip_server/path
http://ip_server/path?query

This is a URL accessing a web (HTTP) server. The default port is 80. If the path refers to a directory, the web server will choose what to return; usually if there is a file named "index.html" or "index.htm", its content is returned; otherwise, a list of the files in the current directory (with appropriate links) is generated and returned. An example is <http://lwn.net>. ๐ŸŒ

A query can be given in the archaic "isindex" format, consisting of a word or phrase and not including an equal sign (=). A query can also be in the longer "GET" format, which has one or more query entries of the form key=value separated by the ampersand character (&). Note that key can be repeated more than once, though it's up to the web server and its application programs to determine if there's any meaning to that. ๐Ÿคทโ™€๏ธ

There is an unfortunate interaction with HTML/XML/SGML and the GET query format; when such URIs with more than one key are embedded in SGML/XML documents (including HTML), the ampersand (&) has to be rewritten as &amp;. ๐Ÿ’€ Not me having to escape my own query strings.

Note that not all queries use this format; larger forms may be too long to store as a URI, so they use a different interaction mechanism (called POST) which does not include the data in the URI. See the Common Gateway Interface specification at http://www.w3.org/CGI for more information.


๐Ÿ’œ ftp โ€” File Transfer Protocol (FTP) ๐Ÿ’œ

ftp://ip_server/path

This is a URL accessing a file through the file transfer protocol (FTP). The default port (for control) is 21. If no username is included, the username "anonymous" is supplied, and in that case many clients provide as the password the requestor's Internet email address. An example is <ftp://ftp.is.co.za/rfc/rfc1808.txt>. ๐Ÿ“


๐Ÿน gopher โ€” Gopher server ๐Ÿน

gopher://ip_server/gophertype selector
gopher://ip_server/gophertype selector%09search
gopher://ip_server/gophertype selector%09search%09gopher+_string

The default gopher port is 70. gophertype is a single-character field to denote the Gopher type of the resource to which the URL refers. The entire path may also be empty, in which case the delimiting "/" is also optional, and the gophertype defaults to "1".

selector is the Gopher selector string. In the Gopher protocol, Gopher selector strings are a sequence of octets which may contain any octets except 09 hexadecimal (US-ASCII HT or tab), 0A hexadecimal (US-ASCII character LF), and 0D (US-ASCII character CR). ๐Ÿšซ no tabs, no line feeds, no carriage returns in your selector, those characters are persona non grata.


๐Ÿ’Œ mailto โ€” Email address ๐Ÿ’Œ

mailto:email-address

This is an email address, usually of the form name@hostname. See mailaddr(7) for more information on the correct format of an email address. Note that any % character must be rewritten as %25. An example is <mailto:dwheeler@dwheeler.com>. ๐Ÿ“


๐Ÿ“ฐ news โ€” Newsgroup or News message ๐Ÿ“ฐ

news:newsgroup-name
news:message-id

A newsgroup-name is a period-delimited hierarchical name, such as "comp.infosystems.www.misc". If <newsgroup-name> is "*" (as in <news:*>), it is used to refer to "all available news groups". An example is <news:comp.lang.ada>.

A message-id corresponds to the Message-ID of IETF RFC 1036, without the enclosing "<" and ">"; it takes the form unique@full_domain_name. A message identifier may be distinguished from a news group name by the presence of the "@" character. ๐Ÿ’… the @ is the tell.


๐Ÿ’ป telnet โ€” Telnet login ๐Ÿ’ป

telnet://ip_server/

The Telnet URL scheme is used to designate interactive text services that may be accessed by the Telnet protocol. The final "/" character may be omitted. The default port is 23. An example is <telnet://melvyl.ucop.edu/>. โœจ


๐ŸŽ€ file โ€” Normal file ๐ŸŽ€

file://ip_server/path_segments
file:path_segments

This represents a file or directory accessible locally. As a special case, ip_server can be the string "localhost" or the empty string; this is interpreted as "the machine from which the URL is being interpreted". If the path is to a directory, the viewer should display the directory's contents with links to each containee; not all viewers currently do this. โš ๏ธ KDE supports generated files through the URL <file:/cgi-bin>. If the given file isn't found, browser writers may want to try to expand the filename via filename globbing (see glob(7) and glob(3)).

The second format (e.g., <file:/etc/passwd>) is a correct format for referring to a local file. However, older standards did not permit this format, and some programs don't recognize this as a URI. A more portable syntax is to use an empty string as the server name, for example, <file:///etc/passwd>; this form does the same thing and is easily recognized by pattern matchers and older programs as a URI. Note that if you really mean to say "start from the current location", don't specify the scheme at all; use a relative address like <../test.txt>, which has the side-effect of being scheme-independent. An example of this scheme is <file:///etc/passwd>. ๐Ÿ—‚๏ธ


๐Ÿ“– man โ€” Man page documentation ๐Ÿ“–

man:command-name
man:command-name(section)

This refers to local online manual (man) reference pages. The command name can optionally be followed by a parenthesis and section number; see man(7) for more information on the meaning of the section numbers. This URI scheme is unique to UNIX-like systems (such as Linux) and is not currently registered by the IETF. An example is <man:ls(1)>. ๐Ÿ‘‘


๐Ÿงš info โ€” Info page documentation ๐Ÿงš

info:virtual-filename
info:virtual-filename#nodename
info:(virtual-filename)
info:(virtual-filename)nodename

This scheme refers to online info reference pages (generated from texinfo files), a documentation format used by programs such as the GNU tools. This URI scheme is unique to UNIX-like systems (such as Linux) and is not currently registered by the IETF. As of this writing, GNOME and KDE differ in their URI syntax and do not accept the other's syntax. ๐Ÿ™ˆ

The first two formats are the GNOME format; in nodenames, all spaces are written as underscores. The second two formats are the KDE format; spaces in nodenames must be written as spaces, even though this is forbidden by the URI standards. ๐Ÿ’€ It's hoped that in the future most tools will understand all of these formats and will always accept underscores for spaces in nodenames. In both GNOME and KDE, if the form without the nodename is used, the nodename is assumed to be "Top".

Examples of the GNOME format are <info:gcc> and <info:gcc#G++_and_GCC>. Examples of the KDE format are <info:(gcc)> and <info:(gcc)G++ and GCC>. ๐ŸŒˆ


whatis:string

This scheme searches the database of short (one-line) descriptions of commands and returns a list of descriptions containing that string. Only complete word matches are returned. See whatis(1). This URI scheme is unique to UNIX-like systems (such as Linux) and is not currently registered by the IETF. ๐ŸŒŸ


๐Ÿซถ ghelp โ€” GNOME help documentation ๐Ÿซถ

ghelp:name-of-application

so this one pulls up GNOME help for whatever application you point it at ๐Ÿซถ. heads up tho: not much documentation currently exists in this format, so manage your expectations a lil bit bestie.


๐Ÿ” ldap โ€” Lightweight Directory Access Protocol ๐Ÿ”

okay so the forms go like this, in order of how much you're filling in:

ldap://hostport
ldap://hostport/
ldap://hostport/dn
ldap://hostport/dn?attributes
ldap://hostport/dn?attributes?scope
ldap://hostport/dn?attributes?scope?filter
ldap://hostport/dn?attributes?scope?filter?extensions

this scheme lets you fire off queries to LDAP, the Lightweight Directory Access Protocol โ€” aka the protocol for asking a whole set of servers for hierarchically organized info (think people, computing resources, that whole vibe). see RFC 2255 for the full deets on the LDAP URL scheme. here's what the pieces are:

  • hostport โ€” the LDAP server you're querying, written as a hostname that may have a colon and the port number tacked on after it. default LDAP port is TCP port 389 ๐Ÿ“. if it's empty, it's on the client to figure out which LDAP server to use.
  • dn โ€” the LDAP Distinguished Name, which identifies the base object of the LDAP search (peep RFC 2253 section 3).
  • attributes โ€” a comma-separated list of the attributes you want returned; see RFC 2251 section 4.1.5. leave it out and all attributes should come back.
  • scope โ€” tells you how wide the search goes. it's one of "base" (base object search), "one" (one-level search), or "sub" (subtree search). omit it and it assumes "base" ๐Ÿ’….
  • filter โ€” the search filter, aka the subset of entries to return. omit it and all entries should come back. see RFC 2254 section 4.
  • extensions โ€” a comma-separated list of type=value pairs, where the =value part can just be left off for options that don't need it. an extension with a '!' in front of it is critical (it has to be supported for the thing to be valid), otherwise it's noncritical (optional).

LDAP queries honestly make the most sense by example, so here we go. this one asks ldap.itd.umich.edu for info about the University of Michigan in the U.S.:

ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US

and if you only want its postal address attribute, you request:

ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress

and to ask host.com at port 6666 about the person with common name (cn) "Babs Jensen" at University of Michigan, you go:

ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)

slay, you did a directory lookup ๐ŸŽ€


๐Ÿ“š wais โ€” Wide Area Information Servers ๐Ÿ“š

three forms, all chill:

wais://hostport/database
wais://hostport/database?search
wais://hostport/database/wtype/wpath

this scheme points at a WAIS database, search, or document (see IETF RFC 1625 for the lore on WAIS). hostport is the hostname, optionally followed by a colon and the port number โ€” and the default port number is 210 โญ.

  • the first form names a WAIS database that's meant for searching.
  • the second form names a particular search of the WAIS database database.
  • the third form names a particular document inside a WAIS database that's gonna get retrieved. wtype is WAIS's designation of the type of the object, and wpath is the WAIS document-id.

๐ŸŒˆ other schemes ๐ŸŒˆ

bestie there are so many other URI schemes out there. most tools that accept URIs support a lil set of internal ones โ€” like, Mozilla has the about: scheme for internal info, and the GNOME help browser has the toc: scheme for various starting locations. there are also a bunch of schemes that have been defined but just aren't as widely used at the current time (e.g., prospero). the nntp: scheme is deprecated in favor of the news: scheme. URNs are supposed to be supported by the urn: scheme, with a hierarchical name space (e.g., urn:ietf:... would identify IETF documents) โ€” but at this time, URNs are not widely implemented ๐Ÿ™ˆ. and fr fr, not all tools support all schemes.


โœจ Character encoding โœจ

URIs only use a limited number of characters, specifically so you can type them in and use them in a whole variety of situations ๐Ÿ’–.

the following characters are reserved, meaning they can show up in a URI but their use is limited to their reserved purpose โ€” so any conflicting data has to be escaped before you form the URI:

; / ? : @ & = + $ ,

Unreserved characters can be included in a URI no problem. unreserved characters include uppercase and lowercase Latin letters, decimal digits, and this limited set of punctuation marks and symbols:

- _ . ! ~ * ' ( )

every other character must be escaped. an escaped octet is encoded as a character triplet: the percent character % followed by the two hexadecimal digits that represent the octet code (and yes you can use uppercase or lowercase letters for those hex digits, either is fine). for example, a blank space must be escaped as "%20", a tab character as "%09", and the "&" as "%26". and because the percent "%" character always has the reserved purpose of being the escape indicator, it must itself be escaped as "%25" ๐Ÿ’€.

it's common practice to escape space characters as the plus symbol (+) in query text. this practice isn't uniformly defined in the relevant RFCs (which recommend %20 instead) but any tool accepting URIs with query text should be prepared for them. a URI is always shown in its "escaped" form.

you can escape unreserved characters without changing the semantics of the URI, but you should not do that unless the URI is being used in a context that doesn't allow the unescaped character to appear. for example, "%7e" is sometimes used instead of "~" in an HTTP URL path, but the two are equivalent for an HTTP URL ๐Ÿ‘‘

for URIs which must handle characters outside the US ASCII character set, the HTML 4.01 specification (section B.2) and IETF RFC 3986 (last paragraph of section 2.5) recommend this approach:

  1. translate the character sequences into UTF-8 (IETF RFC 3629) โ€”see utf-8(7)โ€” and then
  2. use the URI escaping mechanism, that is, use the %HH encoding for unsafe octets.

โœ๏ธ Writing a URI โœ๏ธ

when you write a URI out, it should go inside double quotes (e.g., "http://www.kernel.org"), be enclosed in angle brackets (e.g., <http://lwn.net>), or just be placed on a line by itself. and a heads up for the double-quote girlies: never move extraneous punctuation (like the period ending a sentence, or the comma in a list) inside a URI, bc that will change the value of the URI ๐Ÿ˜ญ. instead, use angle brackets, or switch to a quoting system that never includes extraneous characters inside quotation marks. this latter system โ€” called the 'new' or 'logical' quoting system by "Hart's Rules" and the "Oxford Dictionary for Writers and Editors" โ€” is preferred practice in Great Britain and in various European languages. older documents suggested inserting the prefix "URL:" right before the URI, but that form has never caught on tbh.

the URI syntax was designed to be unambiguous. however, as URIs have become commonplace, traditional media (television, radio, newspapers, billboards, etc.) have increasingly used abbreviated URI references consisting of only the authority and path portions of the identified resource (e.g., <www.w3.org/Addressing>). such references are primarily intended for human interpretation rather than machine, with the assumption that context-based heuristics are enough to complete the URI (e.g., hostnames beginning with "www" are likely to have a URI prefix of "http://" and hostnames beginning with "ftp" likely to have a prefix of "ftp://"). many client implementations heuristically resolve these references. such heuristics may change over time, particularly when new schemes get introduced. and since an abbreviated URI has the same syntax as a relative URL path, abbreviated URI references cannot be used where relative URIs are permitted, and can be used only when there is no defined base (such as in dialog boxes). don't use abbreviated URIs as hypertext links inside a document โ€” use the standard format as described here, periodt ๐Ÿซถ


๐Ÿ“œ STANDARDS ๐Ÿ“œ

โœจ NOTES โœจ

okay bestie, listen up ๐Ÿ’– any tool that takes URIs (think: your web browser, you know the one) on a Linux system should be able to handle โ€” whether directly or indirectly โ€” every single scheme we talked about in this page, and yes that includes man: and info:. and if it handles them by calling some other program instead? totally fine, lowkey encouraged fr fr ๐Ÿซถ

technically?? the fragment isn't part of the URI. just saying. ๐Ÿ™ˆ

if you wanna know how to embed URIs (URLs included) inside a data format, go read the docs for that format, bestie โ€” that's a whole other vibe. but here's the tea:

  • HTML uses the format <A HREF="uri"> text </A>
  • Texinfo files use @uref{uri}
  • Man and mdoc have the recently added UR macro, or you can literally just drop the URI into the text (viewers should be able to detect :// as part of a URI) โœจ

now for the desktop drama ๐ŸŒˆ GNOME and KDE currently vary in the URIs they accept, especially in their help browsers. the way that they differ?? let me count:

  • to list man pages, GNOME uses <toc:man> while KDE uses <man:(index)>
  • to list info pages, GNOME uses <toc:info> while KDE uses <info:(dir)> (the author of this man page prefers the KDE approach here, though a more regular format would be even better โ€” iconic of them to say it ngl)
  • in general, KDE uses <file:/cgi-bin/> as a prefix to a set of generated files
  • KDE prefers documentation in HTML, accessed via the <file:/cgi-bin/helpindex>
  • GNOME prefers the ghelp scheme to store and find documentation

neither browser handles file: references to directories at the time of this writing ๐Ÿ˜ญ which makes it difficult to refer to an entire directory with a browsable URI. and as noted above, these environments differ in how they handle the info: scheme โ€” probably the most important variation. it is expected that GNOME and KDE will converge to common URI formats, and a future version of this man page will describe the converged result. efforts to aid this convergence are encouraged ๐Ÿซก

๐Ÿ”’ Security ๐Ÿ”’

so a URI does not in itself pose a security threat ๐Ÿ’… like, it's just a string boo. BUT. there is no general guarantee that a URL, which at one time located a given resource, will continue to do so. nor is there any guarantee that a URL will not locate a different resource at some later point in time. such a guarantee can be obtained only from the person(s) controlling that namespace and the resource in question. periodt.

โš ๏ธ here's where it gets spooky: it is sometimes possible to construct a URL such that an attempt to perform a seemingly harmless operation โ€” like the retrieval of an entity associated with the resource โ€” will in fact cause a possibly damaging remote operation to occur. ๐Ÿ’€

how?? the unsafe URL is typically constructed by specifying a port number other than that reserved for the network protocol in question. the client then unwittingly contacts a site that is in fact running a different protocol. the content of the URL contains instructions that, when interpreted according to this other protocol, cause an unexpected operation. an example has been the use of a gopher URL to cause an unintended or impersonating message to be sent via a SMTP server. not the vibe. not the vibe at all ๐Ÿ˜ญ

caution should be used when using any URL that specifies a port number other than the default for the protocol โ€” especially when it is a number within the reserved space. ๐Ÿšจ

care should also be taken when a URI contains escaped delimiters for a given protocol (for example, CR and LF characters for telnet protocols) that these are not unescaped before transmission. this might violate the protocol, but it avoids the potential for such characters to be used to simulate an extra operation or parameter in that protocol, which might lead to an unexpected and possibly harmful remote operation being performed. ๐Ÿซฃ

and finally: it is clearly unwise to use a URI that contains a password which is intended to be secret. in particular, the use of a password within the "userinfo" component of a URI is strongly recommended against except in those rare cases where the "password" parameter is intended to be public. like bestie why is your secret in the URL ๐Ÿฅฒ๐Ÿ”


๐Ÿ’€ BUGS ๐Ÿ’€

documentation may be placed in a variety of locations, so there currently isn't a good URI scheme for general online documentation in arbitrary formats. ๐Ÿ˜” references of the form <file:///usr/doc/ZZZ> don't work, because different distributions and local installation requirements may place the files in different directories (it may be in /usr/doc, or /usr/local/doc, or /usr/share, or somewhere else). also, the directory ZZZ usually changes when a version changes (though filename globbing could partially overcome this). and finally, using the file: scheme doesn't easily support people who dynamically load documentation from the Internet (instead of loading the files onto a local filesystem). rough. ๐Ÿ™ˆ

a future URI scheme may be added (e.g., "userdoc:") to permit programs to include cross-references to more detailed documentation without having to know the exact location of that documentation. alternatively, a future version of the filesystem specification may specify file locations sufficiently so that the file: scheme will be able to locate documentation. manifesting this for us โœจ๐Ÿ™

  • many programs and file formats don't include a way to incorporate or implement links using URIs. ๐Ÿ’”
  • many programs can't handle all of these different URI formats; there should be a standard mechanism to load an arbitrary URI that automatically detects the users' environment (e.g., text or graphics, desktop environment, local user preferences, and currently executing tools) and invokes the right tool for any URI. ๐Ÿ‘‘

๐Ÿซถ SEE ALSO ๐Ÿซถ


and that's the whole thing bestie, we ate and left no crumbs ๐Ÿ‘‘ this lil gem is from Linux man-pages 6.20 and it's dated 2026-02-08 โ€” go read uri(7) and slay ๐Ÿ’…โœจ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms