text
stringlengths
17
1.35M
# nmap ## NAME nmap - Network exploration tool and security / port scanner ## SYNOPSIS **nmap**[_Scan Type_...] [_Options_] {_target specification_} ## DESCRIPTION Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. While Nmap is commonly used for security audits, many systems and network administrators find it useful for routine tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. The output from Nmap is a list of scanned targets, with supplemental information on each depending on the options used. Key among that information is the “interesting ports table”. That table lists the port number and protocol, service name, and state. The state is either open, filtered, closed, or unfiltered. Open means that an application on the target machine is listening for connections/packets on that port. Filtered means that a firewall, filter, or other network obstacle is blocking the port so that Nmap cannot tell whether it is open or closed. Closed ports have no application listening on them, though they could open up at any time. Ports are classified as unfiltered when they are responsive to Nmap's probes, but Nmap cannot determine whether they are open or closed. Nmap reports the state combinations open|filtered and closed|filtered when it cannot determine which of the two states describe a port. The port table may also include software version details when version detection has been requested. When an IP protocol scan is requested (**-sO**), Nmap provides information on supported IP protocols rather than listening ports. In addition to the interesting ports table, Nmap can provide further information on targets, including reverse DNS names, operating system guesses, device types, and MAC addresses. A typical Nmap scan is shown in Example 1. The only Nmap arguments used in this example are **-A** , to enable OS and version detection, script scanning, and traceroute; **-T4** for faster execution; and then the hostname. **Example 1. A representative Nmap scan** # **nmap -A -T4 scanme.nmap.org** Nmap scan report for scanme.nmap.org (74.207.244.221) Host is up (0.029s latency). rDNS record for 74.207.244.221: li86-221.members.linode.com Not shown: 995 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 5.3p1 Debian 3ubuntu7 (protocol 2.0) | ssh-hostkey: 1024 8d:60:f1:7c:ca:b7:3d:0a:d6:67:54:9d:69:d9:b9:dd (DSA) |_2048 79:f8:09:ac:d4:e2:32:42:10:49:d3:bd:20:82:85:ec (RSA) 80/tcp open http Apache httpd 2.2.14 ((Ubuntu)) |_http-title: Go ahead and ScanMe! 646/tcp filtered ldp 1720/tcp filtered H.323/Q.931 9929/tcp open nping-echo Nping echo Device type: general purpose Running: Linux 2.6.X OS CPE: cpe:/o:linux:linux_kernel:2.6.39 OS details: Linux 2.6.39 Network Distance: 11 hops Service Info: OS: Linux; CPE: cpe:/o:linux:kernel TRACEROUTE (using port 53/tcp) HOP RTT ADDRESS [Cut first 10 hops for brevity] 11 17.65 ms li86-221.members.linode.com (74.207.244.221) Nmap done: 1 IP address (1 host up) scanned in 14.40 seconds The newest version of Nmap can be obtained from **https://nmap.org ******. The newest version of this man page is available at**https://nmap.org/book/man.html ******. It is also included as a chapter of Nmap Network Scanning: The Official Nmap Project Guide to Network Discovery and Security Scanning (see**https://nmap.org/book/ ******). ## OPTIONS SUMMARY This options summary is printed when Nmap is run with no arguments, and the latest version is always available at **https://svn.nmap.org/nmap/docs/nmap.usage.txt ******. It helps people remember the most common options, but is no substitute for the in-depth documentation in the rest of this manual. Some obscure options aren't even included here. Nmap 7.98SVN (https://nmap.org ) Usage: nmap [Scan Type(s)] [Options] {target specification} TARGET SPECIFICATION: Can pass hostnames, IP addresses, networks, etc. Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 -iL <inputfilename>: Input from list of hosts/networks -iR <num hosts>: Choose random targets --exclude <host1[,host2][,host3],...>: Exclude hosts/networks --excludefile <exclude_file>: Exclude list from file HOST DISCOVERY: -sL: List Scan - simply list targets to scan -sn: Ping Scan - disable port scan -Pn: Treat all hosts as online -- skip host discovery -PS/PA/PU/PY[portlist]: TCP SYN, TCP ACK, UDP or SCTP discovery to given ports -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes -PO[protocol list]: IP Protocol Ping -n/-R: Never do DNS resolution/Always resolve [default: sometimes] --dns-servers <serv1[,serv2],...>: Specify custom DNS servers --system-dns: Use OS's DNS resolver --traceroute: Trace hop path to each host SCAN TECHNIQUES: -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans -sU: UDP Scan -sN/sF/sX: TCP Null, FIN, and Xmas scans --scanflags <flags>: Customize TCP scan flags -sI <zombie host[:probeport]>: Idle scan -sY/sZ: SCTP INIT/COOKIE-ECHO scans -sO: IP protocol scan -b <FTP relay host>: FTP bounce scan PORT SPECIFICATION AND SCAN ORDER: -p <port ranges>: Only scan specified ports Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9 --exclude-ports <port ranges>: Exclude the specified ports from scanning -F: Fast mode - Scan fewer ports than the default scan -r: Scan ports sequentially - don't randomize --top-ports <number>: Scan <number> most common ports --port-ratio <ratio>: Scan ports more common than <ratio> SERVICE/VERSION DETECTION: -sV: Probe open ports to determine service/version info --version-intensity <level>: Set from 0 (light) to 9 (try all probes) --version-light: Limit to most likely probes (intensity 2) --version-all: Try every single probe (intensity 9) --version-trace: Show detailed version scan activity (for debugging) SCRIPT SCAN: -sC: equivalent to --script=default --script=<Lua scripts>: <Lua scripts> is a comma separated list of directories, script-files or script-categories --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts --script-args-file=filename: provide NSE script args in a file --script-trace: Show all data sent and received --script-updatedb: Update the script database. --script-help=<Lua scripts>: Show help about scripts. <Lua scripts> is a comma-separated list of script-files or script-categories. OS DETECTION: -O: Enable OS detection --osscan-limit: Limit OS detection to promising targets --osscan-guess: Guess OS more aggressively TIMING AND PERFORMANCE: Options which take <time> are in seconds, or append 'ms' (milliseconds), 's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m). -T<0-5>: Set timing template (higher is faster) --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes --min-parallelism/max-parallelism <numprobes>: Probe parallelization --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies probe round trip time. --max-retries <tries>: Caps number of port scan probe retransmissions. --host-timeout <time>: Give up on target after this long --scan-delay/--max-scan-delay <time>: Adjust delay between probes --min-rate <number>: Send packets no slower than <number> per second --max-rate <number>: Send packets no faster than <number> per second FIREWALL/IDS EVASION AND SPOOFING: -f; --mtu <val>: fragment packets (optionally w/given MTU) -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys -S <IP_Address>: Spoof source address -e <iface>: Use specified interface -g/--source-port <portnum>: Use given port number --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies --data <hex string>: Append a custom payload to sent packets --data-string <string>: Append a custom ASCII string to sent packets --data-length <num>: Append random data to sent packets --ip-options <options>: Send packets with specified ip options --ttl <val>: Set IP time-to-live field --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address --badsum: Send packets with a bogus TCP/UDP/SCTP checksum OUTPUT: -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3, and Grepable format, respectively, to the given filename. -oA <basename>: Output in the three major formats at once -v: Increase verbosity level (use -vv or more for greater effect) -d: Increase debugging level (use -dd or more for greater effect) --reason: Display the reason a port is in a particular state --open: Only show open (or possibly open) ports --packet-trace: Show all packets sent and received --iflist: Print host interfaces and routes (for debugging) --append-output: Append to rather than clobber specified output files --resume <filename>: Resume an aborted scan --noninteractive: Disable runtime interactions via keyboard --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML --webxml: Reference stylesheet from Nmap.Org for more portable XML --no-stylesheet: Prevent associating of XSL stylesheet w/XML output MISC: -6: Enable IPv6 scanning -A: Enable OS detection, version detection, script scanning, and traceroute --datadir <dirname>: Specify custom Nmap data file location --send-eth/--send-ip: Send using raw ethernet frames or IP packets --privileged: Assume that the user is fully privileged --unprivileged: Assume the user lacks raw socket privileges -V: Print version number -h: Print this help summary page. EXAMPLES: nmap -v -A scanme.nmap.org nmap -v -sn 192.168.0.0/16 10.0.0.0/8 nmap -v -iR 10000 -Pn -p 80 SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES ## TARGET SPECIFICATION Everything on the Nmap command-line that isn't an option (or option argument) is treated as a target host specification. The simplest case is to specify a target IP address or hostname for scanning. When a hostname is given as a target, it is resolved via the Domain Name System (DNS) to determine the IP address to scan. If the name resolves to more than one IP address, only the first one will be scanned. To make Nmap scan all the resolved addresses instead of only the first one, use the **--resolve-all** option. Sometimes you wish to scan a whole network of adjacent hosts. For this, Nmap supports CIDR-style addressing. You can append /_numbits_ to an IP address or hostname and Nmap will scan every IP address for which the first _numbits_ are the same as for the reference IP or hostname given. For example, 192.168.10.0/24 would scan the 256 hosts between 192.168.10.0 (binary: 11000000 10101000 00001010 00000000) and 192.168.10.255 (binary: 11000000 10101000 00001010 11111111), inclusive. 192.168.10.40/24 would scan exactly the same targets. Given that the host scanme.nmap.org is at the IP address 64.13.134.52, the specification scanme.nmap.org/16 would scan the 65,536 IP addresses between 64.13.0.0 and 64.13.255.255. The smallest allowed value is /0, which targets the whole Internet. The largest value for IPv4 is /32, which scans just the named host or IP address because all address bits are fixed. The largest value for IPv6 is /128, which does the same thing. CIDR notation is short but not always flexible enough. For example, you might want to scan 192.168.0.0/16 but skip any IPs ending with .0 or .255 because they may be used as subnet network and broadcast addresses. Nmap supports this through octet range addressing. Rather than specify a normal IP address, you can specify a comma-separated list of numbers or ranges for each octet. For example, 192.168.0-255.1-254 will skip all addresses in the range that end in .0 or .255, and 192.168.3-5,7.1 will scan the four addresses 192.168.3.1, 192.168.4.1, 192.168.5.1, and 192.168.7.1. Either side of a range may be omitted; the default values are 0 on the left and 255 on the right. Using - by itself is the same as 0-255, but remember to use 0- in the first octet so the target specification doesn't look like a command-line option. Ranges need not be limited to the final octets: the specifier 0-255.0-255.13.37 will perform an Internet-wide scan for all IP addresses ending in 13.37. This sort of broad sampling can be useful for Internet surveys and research. IPv6 addresses can be specified by their fully qualified IPv6 address or hostname or with CIDR notation for subnets. Octet ranges aren't yet supported for IPv6. IPv6 addresses with non-global scope need to have a zone ID suffix. On Unix systems, this is a percent sign followed by an interface name; a complete address might be fe80::a8bb:ccff:fedd:eeff%eth0. On Windows, use an interface index number in place of an interface name: fe80::a8bb:ccff:fedd:eeff%1. You can see a list of interface indexes by running the command **netsh.exe interface ipv6 show interface**. Nmap accepts multiple host specifications on the command line, and they don't need to be the same type. The command **nmap** **scanme.nmap.org 192.168.0.0/8 10.0.0,1,3-7.-** does what you would expect. While targets are usually specified on the command lines, the following options are also available to control target selection: **-iL** _inputfilename_ (Input from list) Reads target specifications from _inputfilename_. Passing a huge list of hosts is often awkward on the command line, yet it is a common desire. For example, your DHCP server might export a list of 10,000 current leases that you wish to scan. Or maybe you want to scan all IP addresses _except_ for those to locate hosts using unauthorized static IP addresses. Simply generate the list of hosts to scan and pass that filename to Nmap as an argument to the **-iL** option. Entries can be in any of the formats accepted by Nmap on the command line (IP address, hostname, CIDR, IPv6, or octet ranges). Each entry must be separated by one or more spaces, tabs, or newlines. You can specify a hyphen (-) as the filename if you want Nmap to read hosts from standard input rather than an actual file. The input file may contain comments that start with # and extend to the end of the line. **-iR** _num hosts_ (Choose random targets) For Internet-wide surveys and other research, you may want to choose targets at random. The _num hosts_ argument tells Nmap how many IPs to generate. Undesirable IPs such as those in certain private, multicast, or unallocated address ranges are automatically skipped. The argument 0 can be specified for a never-ending scan. Keep in mind that some network administrators bristle at unauthorized scans of their networks and may complain. Use this option at your own risk! If you find yourself really bored one rainy afternoon, try the command **nmap -Pn -sS -p 80 -iR 0 --open** to locate random web servers for browsing. **--exclude** _host1_**[,**_host2_[,...]] (Exclude hosts/networks) Specifies a comma-separated list of targets to be excluded from the scan even if they are part of the overall network range you specify. The list you pass in uses normal Nmap syntax, so it can include hostnames, CIDR netblocks, octet ranges, etc. This can be useful when the network you wish to scan includes untouchable mission-critical servers, systems that are known to react adversely to port scans, or subnets administered by other people. **--excludefile** _exclude_file_ (Exclude list from file) This offers the same functionality as the **--exclude** option, except that the excluded targets are provided in a newline-, space-, or tab-delimited _exclude_file_ rather than on the command line. The exclude file may contain comments that start with # and extend to the end of the line. **-n**(No reverse DNS resolution) Tells Nmap to _never_ do reverse DNS resolution on the active IP addresses it finds. Since DNS can be slow even with Nmap's built-in parallel stub resolver, this option can slash scanning times. **-R**(Reverse DNS resolution for all targets) Tells Nmap to _always_ do reverse DNS resolution on the target IP addresses. Normally reverse DNS is only performed against responsive (online) hosts. **--resolve-all**(Scan each resolved address) If a hostname target resolves to more than one address, scan all of them. The default behavior is to only scan the first resolved address. Regardless, only addresses in the appropriate address family will be scanned: IPv4 by default, IPv6 with **-6**. **--unique**(Scan each address only once) Scan each IP address only once. The default behavior is to scan each address as many times as it is specified in the target list, such as when network ranges overlap or different hostnames resolve to the same address. **--system-dns**(Use system DNS resolver) By default, Nmap resolves names to IP addresses (and IP addresses to names) by sending queries directly to the name servers configured on your host and then listening for responses. Many requests (often dozens) are performed in parallel to improve performance. Specify this option to use your system resolver instead (one IP at a time via the **getnameinfo** call). This is slower and rarely useful unless you find a bug in the Nmap parallel resolver (please let us know if you do). **--dns-servers** _server1_**[,**_server2_[,...]] (Servers to use for DNS queries) By default, Nmap determines your DNS servers from your resolv.conf file (Unix) or the Registry (Win32). Alternatively, you may use this option to specify alternate servers. This option is not honored if you are using **--system-dns**. Using multiple DNS servers is often faster, especially if you choose authoritative servers for your target IP space. This option can also improve stealth, as your requests can be bounced off just about any recursive DNS server on the Internet. This option also comes in handy when scanning private networks. Sometimes only a few name servers provide proper DNS information, and you may not even know where they are. You can scan the network for port 53 (perhaps with version detection), then try Nmap list scans (**-sL**) specifying each name server one at a time with **--dns-servers** until you find one which works. This option might not be honored if the DNS response exceeds the size of a UDP packet. In such a situation our DNS resolver will make the best effort to extract a response from the truncated packet, and if not successful it will fall back to using the system resolver. ## HOST DISCOVERY One of the very first steps in any network reconnaissance mission is to reduce a (sometimes huge) set of IP ranges into a list of active or interesting hosts. Scanning every port of every single IP address is slow and usually unnecessary. Of course what makes a host interesting depends greatly on the scan purposes. Network administrators may only be interested in hosts running a certain service, while security auditors may care about every single device with an IP address. An administrator may be comfortable using just an ICMP ping to locate hosts on his internal network, while an external penetration tester may use a diverse set of dozens of probes in an attempt to evade firewall restrictions. Because host discovery needs are so diverse, Nmap offers a wide variety of options for customizing the techniques used. Host discovery is sometimes called ping scan, but it goes well beyond the simple ICMP echo request packets associated with the ubiquitous ping tool. Users can skip the discovery step entirely with a list scan (**-sL**) or by disabling host discovery (**-Pn**), or engage the network with arbitrary combinations of multi-port TCP SYN/ACK, UDP, SCTP INIT and ICMP probes. The goal of these probes is to solicit responses which demonstrate that an IP address is actually active (is being used by a host or network device). On many networks, only a small percentage of IP addresses are active at any given time. This is particularly common with private address space such as 10.0.0.0/8. That network has 16 million IPs, but I have seen it used by companies with less than a thousand machines. Host discovery can find those machines in a sparsely allocated sea of IP addresses. If no host discovery options are given, Nmap sends an ICMP echo request, a TCP SYN packet to port 443, a TCP ACK packet to port 80, and an ICMP timestamp request. (For IPv6, the ICMP timestamp request is omitted because it is not part of ICMPv6.) These defaults are equivalent to the **-PE -PS443 -PA80 -PP** options. The exceptions to this are the ARP (for IPv4) and Neighbor Discovery (for IPv6) scans which are used for any targets on a local ethernet network. For unprivileged Unix shell users, the default probes are a SYN packet to ports 80 and 443 using the **connect** system call. This host discovery is often sufficient when scanning local networks, but a more comprehensive set of discovery probes is recommended for security auditing. The **-P*** options (which select ping types) can be combined. You can increase your odds of penetrating strict firewalls by sending many probe types using different TCP ports/flags and ICMP codes. Also note that ARP/Neighbor Discovery is done by default against targets on a local Ethernet network even if you specify other **-P*** options, because it is almost always faster and more effective. By default, Nmap does host discovery and then performs a port scan against each host it determines is online. This is true even if you specify non-default host discovery types such as UDP probes (**-PU**). Read about the **-sn** option to learn how to perform only host discovery, or use **-Pn** to skip host discovery and port scan all target addresses. The following options control host discovery: **-sL**(List Scan) The list scan is a degenerate form of host discovery that simply lists each host of the network(s) specified, without sending any packets to the target hosts. By default, Nmap still does reverse-DNS resolution on the hosts to learn their names. It is often surprising how much useful information simple hostnames give out. For example, fw.chi is the name of one company's Chicago firewall. Nmap also reports the total number of IP addresses at the end. The list scan is a good sanity check to ensure that you have proper IP addresses for your targets. If the hosts sport domain names you do not recognize, it is worth investigating further to prevent scanning the wrong company's network. Since the idea is to simply print a list of target hosts, options for higher level functionality such as port scanning, OS detection, or host discovery cannot be combined with this. If you wish to disable host discovery while still performing such higher level functionality, read up on the **-Pn**(skip host discovery) option. **-sn**(No port scan) This option tells Nmap not to do a port scan after host discovery, and only print out the available hosts that responded to the host discovery probes. This is often known as a “ping scan”, but you can also request that traceroute and NSE host scripts be run. This is by default one step more intrusive than the list scan, and can often be used for the same purposes. It allows light reconnaissance of a target network without attracting much attention. Knowing how many hosts are up is more valuable to attackers than the list provided by list scan of every single IP and host name. Systems administrators often find this option valuable as well. It can easily be used to count available machines on a network or monitor server availability. This is often called a ping sweep, and is more reliable than pinging the broadcast address because many hosts do not reply to broadcast queries. The default host discovery done with **-sn** consists of an ICMP echo request, TCP SYN to port 443, TCP ACK to port 80, and an ICMP timestamp request by default. When executed by an unprivileged user, only SYN packets are sent (using a **connect** call) to ports 80 and 443 on the target. When a privileged user tries to scan targets on a local ethernet network, ARP requests are used unless **--send-ip** was specified. The **-sn** option can be combined with any of the discovery probe types (the **-P*** options) for greater flexibility. If any of those probe type and port number options are used, the default probes are overridden. When strict firewalls are in place between the source host running Nmap and the target network, using those advanced techniques is recommended. Otherwise hosts could be missed when the firewall drops probes or their responses. In previous releases of Nmap, **-sn** was known as **-sP**. **-Pn**(No ping) This option skips the host discovery stage altogether. Normally, Nmap uses this stage to determine active machines for heavier scanning and to gauge the speed of the network. By default, Nmap only performs heavy probing such as port scans, version detection, or OS detection against hosts that are found to be up. Disabling host discovery with **-Pn** causes Nmap to attempt the requested scanning functions against _every_ target IP address specified. So if a /16 sized network is specified on the command line, all 65,536 IP addresses are scanned. Proper host discovery is skipped as with the list scan, but instead of stopping and printing the target list, Nmap continues to perform requested functions as if each target IP is active. Default timing parameters are used, which may result in slower scans. To skip host discovery _and_ port scan, while still allowing NSE to run, use the two options **-Pn** **-sn** together. For machines on a local ethernet network, ARP scanning will still be performed (unless **--disable-arp-ping** or **--send-ip** is specified) because Nmap needs MAC addresses to further scan target hosts. In previous versions of Nmap, **-Pn** was **-P0** and **-PN**. **-PS** _port list_ (TCP SYN Ping) This option sends an empty TCP packet with the SYN flag set. The default destination port is 80 (configurable at compile time by changing _DEFAULT_TCP_PROBE_PORT_SPEC_ in nmap.h). Alternate ports can be specified as a parameter. The syntax is the same as for the **-p** except that port type specifiers like T: are not allowed. Examples are **-PS22** and **-PS22-25,80,113,1050,35000**. Note that there can be no space between **-PS** and the port list. If multiple probes are specified they will be sent in parallel. The SYN flag suggests to the remote system that you are attempting to establish a connection. Normally the destination port will be closed, and a RST (reset) packet sent back. If the port happens to be open, the target will take the second step of a TCP three-way-handshake by responding with a SYN/ACK TCP packet. The machine running Nmap then tears down the nascent connection by responding with a RST rather than sending an ACK packet which would complete the three-way-handshake and establish a full connection. The RST packet is sent by the kernel of the machine running Nmap in response to the unexpected SYN/ACK, not by Nmap itself. Nmap does not care whether the port is open or closed. Either the RST or SYN/ACK response discussed previously tell Nmap that the host is available and responsive. On Unix boxes, only the privileged user root is generally able to send and receive raw TCP packets. For unprivileged users, a workaround is automatically employed whereby the **connect** system call is initiated against each target port. This has the effect of sending a SYN packet to the target host, in an attempt to establish a connection. If **connect** returns with a quick success or an ECONNREFUSED failure, the underlying TCP stack must have received a SYN/ACK or RST and the host is marked available. If the connection attempt is left hanging until a timeout is reached, the host is marked as down. **-PA** _port list_ (TCP ACK Ping) The TCP ACK ping is quite similar to the just-discussed SYN ping. The difference, as you could likely guess, is that the TCP ACK flag is set instead of the SYN flag. Such an ACK packet purports to be acknowledging data over an established TCP connection, but no such connection exists. So remote hosts should always respond with a RST packet, disclosing their existence in the process. The **-PA** option uses the same default port as the SYN probe (80) and can also take a list of destination ports in the same format. If an unprivileged user tries this, the **connect** workaround discussed previously is used. This workaround is imperfect because **connect** is actually sending a SYN packet rather than an ACK. The reason for offering both SYN and ACK ping probes is to maximize the chances of bypassing firewalls. Many administrators configure routers and other simple firewalls to block incoming SYN packets except for those destined for public services like the company web site or mail server. This prevents other incoming connections to the organization, while allowing users to make unobstructed outgoing connections to the Internet. This non-stateful approach takes up few resources on the firewall/router and is widely supported by hardware and software filters. The Linux Netfilter/iptables firewall software offers the **--syn** convenience option to implement this stateless approach. When stateless firewall rules such as this are in place, SYN ping probes (**-PS**) are likely to be blocked when sent to closed target ports. In such cases, the ACK probe shines as it cuts right through these rules. Another common type of firewall uses stateful rules that drop unexpected packets. This feature was initially found mostly on high-end firewalls, though it has become much more common over the years. The Linux Netfilter/iptables system supports this through the **--state** option, which categorizes packets based on connection state. A SYN probe is more likely to work against such a system, as unexpected ACK packets are generally recognized as bogus and dropped. A solution to this quandary is to send both SYN and ACK probes by specifying **-PS** and **-PA**. **-PU** _port list_ (UDP Ping) Another host discovery option is the UDP ping, which sends a UDP packet to the given ports. For most ports, the packet will be empty, though some use a protocol-specific payload that is more likely to elicit a response. The payloads are the same probes used in service and version detection and are defined in the nmap-service-probes file. Packet content can also be affected with the **--data** , **--data-string** , and **--data-length** options. The port list takes the same format as with the previously discussed **-PS** and **-PA** options. If no ports are specified, the default is 40125. This default can be configured at compile-time by changing _DEFAULT_UDP_PROBE_PORT_SPEC_ in nmap.h. A highly uncommon port is used by default because sending to open ports is often undesirable for this particular scan type. Upon hitting a closed port on the target machine, the UDP probe should elicit an ICMP port unreachable packet in return. This signifies to Nmap that the machine is up and available. Many other types of ICMP errors, such as host/network unreachables or TTL exceeded are indicative of a down or unreachable host. A lack of response is also interpreted this way. If an open port is reached, most services simply ignore the empty packet and fail to return any response. This is why the default probe port is 40125, which is highly unlikely to be in use. A few services, such as the Character Generator (chargen) protocol, will respond to an empty UDP packet, and thus disclose to Nmap that the machine is available. The primary advantage of this scan type is that it bypasses firewalls and filters that only screen TCP. For example, I once owned a Linksys BEFW11S4 wireless broadband router. The external interface of this device filtered all TCP ports by default, but UDP probes would still elicit port unreachable messages and thus give away the device. **-PY** _port list_ (SCTP INIT Ping) This option sends an SCTP packet containing a minimal INIT chunk. The default destination port is 80 (configurable at compile time by changing _DEFAULT_SCTP_PROBE_PORT_SPEC_ in nmap.h). Alternate ports can be specified as a parameter. The syntax is the same as for the **-p** except that port type specifiers like S: are not allowed. Examples are **-PY22** and **-PY22,80,179,5060**. Note that there can be no space between **-PY** and the port list. If multiple probes are specified they will be sent in parallel. The INIT chunk suggests to the remote system that you are attempting to establish an association. Normally the destination port will be closed, and an ABORT chunk will be sent back. If the port happens to be open, the target will take the second step of an SCTP four-way-handshake by responding with an INIT-ACK chunk. If the machine running Nmap has a functional SCTP stack, then it tears down the nascent association by responding with an ABORT chunk rather than sending a COOKIE-ECHO chunk which would be the next step in the four-way-handshake. The ABORT packet is sent by the kernel of the machine running Nmap in response to the unexpected INIT-ACK, not by Nmap itself. Nmap does not care whether the port is open or closed. Either the ABORT or INIT-ACK response discussed previously tell Nmap that the host is available and responsive. On Unix boxes, only the privileged user root is generally able to send and receive raw SCTP packets. Using SCTP INIT Pings is currently not possible for unprivileged users. **-PE** ; **-PP** ; **-PM**(ICMP Ping Types) In addition to the unusual TCP, UDP and SCTP host discovery types discussed previously, Nmap can send the standard packets sent by the ubiquitous ping program. Nmap sends an ICMP type 8 (echo request) packet to the target IP addresses, expecting a type 0 (echo reply) in return from available hosts. Unfortunately for network explorers, many hosts and firewalls now block these packets, rather than responding as required by **RFC 1122******[2]. For this reason, ICMP-only scans are rarely reliable enough against unknown targets over the Internet. But for system administrators monitoring an internal network, they can be a practical and efficient approach. Use the**-PE** option to enable this echo request behavior. While echo request is the standard ICMP ping query, Nmap does not stop there. The ICMP standards (**RFC 792******[3] and**RFC 950******[4] ) also specify timestamp request, information request, and address mask request packets as codes 13, 15, and 17, respectively. While the ostensible purpose for these queries is to learn information such as address masks and current times, they can easily be used for host discovery. A system that replies is up and available. Nmap does not currently implement information request packets, as they are not widely supported. RFC 1122 insists that “a host SHOULD NOT implement these messages”. Timestamp and address mask queries can be sent with the**-PP** and **-PM** options, respectively. A timestamp reply (ICMP code 14) or address mask reply (code 18) discloses that the host is available. These two queries can be valuable when administrators specifically block echo request packets while forgetting that other ICMP queries can be used for the same purpose. **-PO** _protocol list_ (IP Protocol Ping) One of the newer host discovery options is the IP protocol ping, which sends IP packets with the specified protocol number set in their IP header. The protocol list takes the same format as do port lists in the previously discussed TCP, UDP and SCTP host discovery options. If no protocols are specified, the default is to send multiple IP packets for ICMP (protocol 1), IGMP (protocol 2), and IP-in-IP (protocol 4). The default protocols can be configured at compile-time by changing _DEFAULT_PROTO_PROBE_PORT_SPEC_ in nmap.h. Note that for the ICMP, IGMP, TCP (protocol 6), UDP (protocol 17) and SCTP (protocol 132), the packets are sent with the proper protocol headers while other protocols are sent with no additional data beyond the IP header (unless any of **--data** , **--data-string** , or **--data-length** options are specified). This host discovery method looks for either responses using the same protocol as a probe, or ICMP protocol unreachable messages which signify that the given protocol isn't supported on the destination host. Either type of response signifies that the target host is alive. **--disable-arp-ping**(No ARP or ND Ping) Nmap normally does ARP or IPv6 Neighbor Discovery (ND) discovery of locally connected ethernet hosts, even if other host discovery options such as **-Pn** or **-PE** are used. To disable this implicit behavior, use the **--disable-arp-ping** option. The default behavior is normally faster, but this option is useful on networks using proxy ARP, in which a router speculatively replies to all ARP requests, making every target appear to be up according to ARP scan. **--discovery-ignore-rst** In some cases, firewalls may spoof TCP reset (RST) replies in response to probes to unoccupied or disallowed addresses. Since Nmap ordinarily considers RST replies to be proof that the target is up, this can lead to wasted time scanning targets that aren't there. Using the **--discovery-ignore-rst** will prevent Nmap from considering these replies during host discovery. You may need to select extra host discovery options to ensure you don't miss targets in this case. **--traceroute**(Trace path to host) Traceroutes are performed post-scan using information from the scan results to determine the port and protocol most likely to reach the target. It works with all scan types except connect scans (**-sT**) and idle scans (**-sI**). All traces use Nmap's dynamic timing model and are performed in parallel. Traceroute works by sending packets with a low TTL (time-to-live) in an attempt to elicit ICMP Time Exceeded messages from intermediate hops between the scanner and the target host. Standard traceroute implementations start with a TTL of 1 and increment the TTL until the destination host is reached. Nmap's traceroute starts with a high TTL and then decrements the TTL until it reaches zero. Doing it backwards lets Nmap employ clever caching algorithms to speed up traces over multiple hosts. On average Nmap sends 5–10 fewer packets per host, depending on network conditions. If a single subnet is being scanned (i.e. 192.168.0.0/24) Nmap may only have to send two packets to most hosts. ## PORT SCANNING BASICS While Nmap has grown in functionality over the years, it began as an efficient port scanner, and that remains its core function. The simple command **nmap** _target_ scans 1,000 TCP ports on the host _target_. While many port scanners have traditionally lumped all ports into the open or closed states, Nmap is much more granular. It divides ports into six states: open, closed, filtered, unfiltered, open|filtered, or closed|filtered. These states are not intrinsic properties of the port itself, but describe how Nmap sees them. For example, an Nmap scan from the same network as the target may show port 135/tcp as open, while a scan at the same time with the same options from across the Internet might show that port as filtered. **The six port states recognized by Nmap** open An application is actively accepting TCP connections, UDP datagrams or SCTP associations on this port. Finding these is often the primary goal of port scanning. Security-minded people know that each open port is an avenue for attack. Attackers and pen-testers want to exploit the open ports, while administrators try to close or protect them with firewalls without thwarting legitimate users. Open ports are also interesting for non-security scans because they show services available for use on the network. closed A closed port is accessible (it receives and responds to Nmap probe packets), but there is no application listening on it. They can be helpful in showing that a host is up on an IP address (host discovery, or ping scanning), and as part of OS detection. Because closed ports are reachable, it may be worth scanning later in case some open up. Administrators may want to consider blocking such ports with a firewall. Then they would appear in the filtered state, discussed next. filtered Nmap cannot determine whether the port is open because packet filtering prevents its probes from reaching the port. The filtering could be from a dedicated firewall device, router rules, or host-based firewall software. These ports frustrate attackers because they provide so little information. Sometimes they respond with ICMP error messages such as type 3 code 13 (destination unreachable: communication administratively prohibited), but filters that simply drop probes without responding are far more common. This forces Nmap to retry several times just in case the probe was dropped due to network congestion rather than filtering. This slows down the scan dramatically. unfiltered The unfiltered state means that a port is accessible, but Nmap is unable to determine whether it is open or closed. Only the ACK scan, which is used to map firewall rulesets, classifies ports into this state. Scanning unfiltered ports with other scan types such as Window scan, SYN scan, or FIN scan, may help resolve whether the port is open. open|filtered Nmap places ports in this state when it is unable to determine whether a port is open or filtered. This occurs for scan types in which open ports give no response. The lack of response could also mean that a packet filter dropped the probe or any response it elicited. So Nmap does not know for sure whether the port is open or being filtered. The UDP, IP protocol, FIN, NULL, and Xmas scans classify ports this way. closed|filtered This state is used when Nmap is unable to determine whether a port is closed or filtered. It is only used for the IP ID idle scan. ## PORT SCANNING TECHNIQUES As a novice performing automotive repair, I can struggle for hours trying to fit my rudimentary tools (hammer, duct tape, wrench, etc.) to the task at hand. When I fail miserably and tow my jalopy to a real mechanic, he invariably fishes around in a huge tool chest until pulling out the perfect gizmo which makes the job seem effortless. The art of port scanning is similar. Experts understand the dozens of scan techniques and choose the appropriate one (or combination) for a given task. Inexperienced users and script kiddies, on the other hand, try to solve every problem with the default SYN scan. Since Nmap is free, the only barrier to port scanning mastery is knowledge. That certainly beats the automotive world, where it may take great skill to determine that you need a strut spring compressor, then you still have to pay thousands of dollars for it. Most of the scan types are only available to privileged users. This is because they send and receive raw packets, which requires root access on Unix systems. Using an administrator account on Windows is recommended, though Nmap sometimes works for unprivileged users on that platform when Npcap has already been loaded into the OS. Requiring root privileges was a serious limitation when Nmap was released in 1997, as many users only had access to shared shell accounts. Now, the world is different. Computers are cheaper, far more people have always-on direct Internet access, and desktop Unix systems (including Linux and Mac OS X) are prevalent. A Windows version of Nmap is now available, allowing it to run on even more desktops. For all these reasons, users have less need to run Nmap from limited shared shell accounts. This is fortunate, as the privileged options make Nmap far more powerful and flexible. While Nmap attempts to produce accurate results, keep in mind that all of its insights are based on packets returned by the target machines (or firewalls in front of them). Such hosts may be untrustworthy and send responses intended to confuse or mislead Nmap. Much more common are non-RFC-compliant hosts that do not respond as they should to Nmap probes. FIN, NULL, and Xmas scans are particularly susceptible to this problem. Such issues are specific to certain scan types and so are discussed in the individual scan type entries. This section documents the dozen or so port scan techniques supported by Nmap. Only one method may be used at a time, except that UDP scan (**-sU**) and any one of the SCTP scan types (**-sY** , **-sZ**) may be combined with any one of the TCP scan types. As a memory aid, port scan type options are of the form **-s** _C_ , where _C_ is a prominent character in the scan name, usually the first. The one exception to this is the deprecated FTP bounce scan (**-b**). By default, Nmap performs a SYN Scan, though it substitutes a connect scan if the user does not have proper privileges to send raw packets (requires root access on Unix). Of the scans listed in this section, unprivileged users can only execute connect and FTP bounce scans. **-sS**(TCP SYN scan) SYN scan is the default and most popular scan option for good reasons. It can be performed quickly, scanning thousands of ports per second on a fast network not hampered by restrictive firewalls. It is also relatively unobtrusive and stealthy since it never completes TCP connections. SYN scan works against any compliant TCP stack rather than depending on idiosyncrasies of specific platforms as Nmap's FIN/NULL/Xmas, Maimon and idle scans do. It also allows clear, reliable differentiation between the open, closed, and filtered states. This technique is often referred to as half-open scanning, because you don't open a full TCP connection. You send a SYN packet, as if you are going to open a real connection and then wait for a response. A SYN/ACK indicates the port is listening (open), while a RST (reset) is indicative of a non-listener. If no response is received after several retransmissions, the port is marked as filtered. The port is also marked filtered if an ICMP unreachable error (type 3, code 0, 1, 2, 3, 9, 10, or 13) is received. The port is also considered open if a SYN packet (without the ACK flag) is received in response. This can be due to an extremely rare TCP feature known as a simultaneous open or split handshake connection (see **https://nmap.org/misc/split-handshake.pdf ******).**-sT**(TCP connect scan) TCP connect scan is the default TCP scan type when SYN scan is not an option. This is the case when a user does not have raw packet privileges. Instead of writing raw packets as most other scan types do, Nmap asks the underlying operating system to establish a connection with the target machine and port by issuing the **connect** system call. This is the same high-level system call that web browsers, P2P clients, and most other network-enabled applications use to establish a connection. It is part of a programming interface known as the Berkeley Sockets API. Rather than read raw packet responses off the wire, Nmap uses this API to obtain status information on each connection attempt. When SYN scan is available, it is usually a better choice. Nmap has less control over the high level **connect** call than with raw packets, making it less efficient. The system call completes connections to open target ports rather than performing the half-open reset that SYN scan does. Not only does this take longer and require more packets to obtain the same information, but target machines are more likely to log the connection. A decent IDS will catch either, but most machines have no such alarm system. Many services on your average Unix system will add a note to syslog, and sometimes a cryptic error message, when Nmap connects and then closes the connection without sending data. Truly pathetic services crash when this happens, though that is uncommon. An administrator who sees a bunch of connection attempts in her logs from a single system should know that she has been connect scanned. **-sU**(UDP scans) While most popular services on the Internet run over the TCP protocol, **UDP******[5] services are widely deployed. DNS, SNMP, and DHCP (registered ports 53, 161/162, and 67/68) are three of the most common. Because UDP scanning is generally slower and more difficult than TCP, some security auditors ignore these ports. This is a mistake, as exploitable UDP services are quite common and attackers certainly don't ignore the whole protocol. Fortunately, Nmap can help inventory UDP ports. UDP scan is activated with the**-sU** option. It can be combined with a TCP scan type such as SYN scan (**-sS**) to check both protocols during the same run. UDP scan works by sending a UDP packet to every targeted port. For some common ports such as 53 and 161, a protocol-specific payload is sent to increase response rate, but for most ports the packet is empty unless the **--data** , **--data-string** , or **--data-length** options are specified. If an ICMP port unreachable error (type 3, code 3) is returned, the port is closed. Other ICMP unreachable errors (type 3, codes 0, 1, 2, 9, 10, or 13) mark the port as filtered. Occasionally, a service will respond with a UDP packet, proving that it is open. If no response is received after retransmissions, the port is classified as open|filtered. This means that the port could be open, or perhaps packet filters are blocking the communication. Version detection (**-sV**) can be used to help differentiate the truly open ports from the filtered ones. A big challenge with UDP scanning is doing it quickly. Open and filtered ports rarely send any response, leaving Nmap to time out and then conduct retransmissions just in case the probe or response were lost. Closed ports are often an even bigger problem. They usually send back an ICMP port unreachable error. But unlike the RST packets sent by closed TCP ports in response to a SYN or connect scan, many hosts rate limit ICMP port unreachable messages by default. Linux and Solaris are particularly strict about this. For example, the Linux 2.4.20 kernel limits destination unreachable messages to one per second (in net/ipv4/icmp.c). Nmap detects rate limiting and slows down accordingly to avoid flooding the network with useless packets that the target machine will drop. Unfortunately, a Linux-style limit of one packet per second makes a 65,536-port scan take more than 18 hours. Ideas for speeding your UDP scans up include scanning more hosts in parallel, doing a quick scan of just the popular ports first, scanning from behind the firewall, and using **--host-timeout** to skip slow hosts. **-sY**(SCTP INIT scan) **SCTP******[6] is a relatively new alternative to the TCP and UDP protocols, combining most characteristics of TCP and UDP, and also adding new features like multi-homing and multi-streaming. It is mostly being used for SS7/SIGTRAN related services but has the potential to be used for other applications as well. SCTP INIT scan is the SCTP equivalent of a TCP SYN scan. It can be performed quickly, scanning thousands of ports per second on a fast network not hampered by restrictive firewalls. Like SYN scan, INIT scan is relatively unobtrusive and stealthy, since it never completes SCTP associations. It also allows clear, reliable differentiation between the open, closed, and filtered states. This technique is often referred to as half-open scanning, because you don't open a full SCTP association. You send an INIT chunk, as if you are going to open a real association and then wait for a response. An INIT-ACK chunk indicates the port is listening (open), while an ABORT chunk is indicative of a non-listener. If no response is received after several retransmissions, the port is marked as filtered. The port is also marked filtered if an ICMP unreachable error (type 3, code 0, 1, 2, 3, 9, 10, or 13) is received.**-sN** ; **-sF** ; **-sX**(TCP NULL, FIN, and Xmas scans) These three scan types (even more are possible with the **--scanflags** option described in the next section) exploit a subtle loophole in the **TCP RFC******[7] to differentiate between open and closed ports. Page 65 of RFC 793 says that “if the [destination] port state is CLOSED .... an incoming segment not containing a RST causes a RST to be sent in response.” Then the next page discusses packets sent to open ports without the SYN, RST, or ACK bits set, stating that: “you are unlikely to get here, but if you do, drop the segment, and return.” When scanning systems compliant with this RFC text, any packet not containing SYN, RST, or ACK bits will result in a returned RST if the port is closed and no response at all if the port is open. As long as none of those three bits are included, any combination of the other three (FIN, PSH, and URG) are OK. Nmap exploits this with three scan types: Null scan (**-sN**) Does not set any bits (TCP flag header is 0) FIN scan (**-sF**) Sets just the TCP FIN bit. Xmas scan (**-sX**) Sets the FIN, PSH, and URG flags, lighting the packet up like a Christmas tree. These three scan types are exactly the same in behavior except for the TCP flags set in probe packets. If a RST packet is received, the port is considered closed, while no response means it is open|filtered. The port is marked filtered if an ICMP unreachable error (type 3, code 0, 1, 2, 3, 9, 10, or 13) is received. The key advantage to these scan types is that they can sneak through certain non-stateful firewalls and packet filtering routers. Another advantage is that these scan types are a little more stealthy than even a SYN scan. Don't count on this though—most modern IDS products can be configured to detect them. The big downside is that not all systems follow RFC 793 to the letter. A number of systems send RST responses to the probes regardless of whether the port is open or not. This causes all of the ports to be labeled closed. Major operating systems that do this are Microsoft Windows, many Cisco devices, BSDI, and IBM OS/400. This scan does work against most Unix-based systems though. Another downside of these scans is that they can't distinguish open ports from certain filtered ones, leaving you with the response open|filtered. **-sA**(TCP ACK scan) This scan is different than the others discussed so far in that it never determines open (or even open|filtered) ports. It is used to map out firewall rulesets, determining whether they are stateful or not and which ports are filtered. The ACK scan probe packet has only the ACK flag set (unless you use **--scanflags**). When scanning unfiltered systems, open and closed ports will both return a RST packet. Nmap then labels them as unfiltered, meaning that they are reachable by the ACK packet, but whether they are open or closed is undetermined. Ports that don't respond, or send certain ICMP error messages back (type 3, code 0, 1, 2, 3, 9, 10, or 13), are labeled filtered. **-sW**(TCP Window scan) Window scan is exactly the same as ACK scan except that it exploits an implementation detail of certain systems to differentiate open ports from closed ones, rather than always printing unfiltered when a RST is returned. It does this by examining the TCP Window field of the RST packets returned. On some systems, open ports use a positive window size (even for RST packets) while closed ones have a zero window. So instead of always listing a port as unfiltered when it receives a RST back, Window scan lists the port as open or closed if the TCP Window value in that reset is positive or zero, respectively. This scan relies on an implementation detail of a minority of systems out on the Internet, so you can't always trust it. Systems that don't support it will usually return all ports closed. Of course, it is possible that the machine really has no open ports. If most scanned ports are closed but a few common port numbers (such as 22, 25, 53) are filtered, the system is most likely susceptible. Occasionally, systems will even show the exact opposite behavior. If your scan shows 1,000 open ports and three closed or filtered ports, then those three may very well be the truly open ones. **-sM**(TCP Maimon scan) The Maimon scan is named after its discoverer, Uriel Maimon. He described the technique in Phrack Magazine issue #49 (November 1996). Nmap, which included this technique, was released two issues later. This technique is exactly the same as NULL, FIN, and Xmas scans, except that the probe is FIN/ACK. According to **RFC 793******[7] (TCP), a RST packet should be generated in response to such a probe whether the port is open or closed. However, Uriel noticed that many BSD-derived systems simply drop the packet if the port is open.**--scanflags**(Custom TCP scan) Truly advanced Nmap users need not limit themselves to the canned scan types offered. The **--scanflags** option allows you to design your own scan by specifying arbitrary TCP flags. Let your creative juices flow, while evading intrusion detection systems whose vendors simply paged through the Nmap man page adding specific rules! The **--scanflags** argument can be a numerical flag value such as 9 (PSH and FIN), but using symbolic names is easier. Just mash together any combination of URG, ACK, PSH, RST, SYN, and FIN. For example, **--scanflags URGACKPSHRSTSYNFIN** sets everything, though it's not very useful for scanning. The order these are specified in is irrelevant. In addition to specifying the desired flags, you can specify a TCP scan type (such as **-sA** or **-sF**). That base type tells Nmap how to interpret responses. For example, a SYN scan considers no-response to indicate a filtered port, while a FIN scan treats the same as open|filtered. Nmap will behave the same way it does for the base scan type, except that it will use the TCP flags you specify instead. If you don't specify a base type, SYN scan is used. **-sZ**(SCTP COOKIE ECHO scan) SCTP COOKIE ECHO scan is a more advanced SCTP scan. It takes advantage of the fact that SCTP implementations should silently drop packets containing COOKIE ECHO chunks on open ports, but send an ABORT if the port is closed. The advantage of this scan type is that it is not as obvious a port scan than an INIT scan. Also, there may be non-stateful firewall rulesets blocking INIT chunks, but not COOKIE ECHO chunks. Don't be fooled into thinking that this will make a port scan invisible; a good IDS will be able to detect SCTP COOKIE ECHO scans too. The downside is that SCTP COOKIE ECHO scans cannot differentiate between open and filtered ports, leaving you with the state open|filtered in both cases. **-sI** _zombie host_**[:**_probeport_] (idle scan) This advanced scan method allows for a truly blind TCP port scan of the target (meaning no packets are sent to the target from your real IP address). Instead, a unique side-channel attack exploits predictable IP fragmentation ID sequence generation on the zombie host to glean information about the open ports on the target. IDS systems will display the scan as coming from the zombie machine you specify (which must be up and meet certain criteria). This fascinating scan type is too complex to fully describe in this reference guide, so I wrote and posted an informal paper with full details at **https://nmap.org/book/idlescan.html ******. Besides being extraordinarily stealthy (due to its blind nature), this scan type permits mapping out IP-based trust relationships between machines. The port listing shows open ports _from the perspective of the zombie host._ So you can try scanning a target using various zombies that you think might be trusted (via router/packet filter rules). You can add a colon followed by a port number to the zombie host if you wish to probe a particular port on the zombie for IP ID changes. Otherwise Nmap will use the port it uses by default for TCP pings (80). **-sO**(IP protocol scan) IP protocol scan allows you to determine which IP protocols (TCP, ICMP, IGMP, etc.) are supported by target machines. This isn't technically a port scan, since it cycles through IP protocol numbers rather than TCP or UDP port numbers. Yet it still uses the **-p** option to select scanned protocol numbers, reports its results within the normal port table format, and even uses the same underlying scan engine as the true port scanning methods. So it is close enough to a port scan that it belongs here. Besides being useful in its own right, protocol scan demonstrates the power of open-source software. While the fundamental idea is pretty simple, I had not thought to add it nor received any requests for such functionality. Then in the summer of 2000, Gerhard Rieger conceived the idea, wrote an excellent patch implementing it, and sent it to the announce mailing list (then called nmap-hackers). I incorporated that patch into the Nmap tree and released a new version the next day. Few pieces of commercial software have users enthusiastic enough to design and contribute their own improvements! Protocol scan works in a similar fashion to UDP scan. Instead of iterating through the port number field of a UDP packet, it sends IP packet headers and iterates through the eight-bit IP protocol field. The headers are usually empty, containing no data and not even the proper header for the claimed protocol. The exceptions are TCP, UDP, ICMP, SCTP, and IGMP. A proper protocol header for those is included since some systems won't send them otherwise and because Nmap already has functions to create them. Instead of watching for ICMP port unreachable messages, protocol scan is on the lookout for ICMP _protocol_ unreachable messages. If Nmap receives any response in any protocol from the target host, Nmap marks that protocol as open. An ICMP protocol unreachable error (type 3, code 2) causes the protocol to be marked as closed while port unreachable (type 3, code 3) marks the protocol open. Other ICMP unreachable errors (type 3, code 0, 1, 9, 10, or 13) cause the protocol to be marked filtered (though they prove that ICMP is open at the same time). If no response is received after retransmissions, the protocol is marked open|filtered **-b** _FTP relay host_ (FTP bounce scan) An interesting feature of the FTP protocol (**RFC 959******[8]) is support for so-called proxy FTP connections. This allows a user to connect to one FTP server, then ask that files be sent to a third-party server. Such a feature is ripe for abuse on many levels, so most servers have ceased supporting it. One of the abuses this feature allows is causing the FTP server to port scan other hosts. Simply ask the FTP server to send a file to each interesting port of a target host in turn. The error message will describe whether the port is open or not. This is a good way to bypass firewalls because organizational FTP servers are often placed where they have more access to other internal hosts than any old Internet host would. Nmap supports FTP bounce scan with the**-b** option. It takes an argument of the form _username_ :_password_ @_server_ :_port_. _Server_ is the name or IP address of a vulnerable FTP server. As with a normal URL, you may omit _username_ :_password_ , in which case anonymous login credentials (user: anonymous password:-wwwuser@) are used. The port number (and preceding colon) may be omitted as well, in which case the default FTP port (21) on _server_ is used. This vulnerability was widespread in 1997 when Nmap was released, but has largely been fixed. Vulnerable servers are still around, so it is worth trying when all else fails. If bypassing a firewall is your goal, scan the target network for port 21 (or even for any FTP services if you scan all ports with version detection) and use the ftp-bounce NSE script. Nmap will tell you whether the host is vulnerable or not. If you are just trying to cover your tracks, you don't need to (and, in fact, shouldn't) limit yourself to hosts on the target network. Before you go scanning random Internet addresses for vulnerable FTP servers, consider that sysadmins may not appreciate you abusing their servers in this way. ## PORT SPECIFICATION AND SCAN ORDER In addition to all of the scan methods discussed previously, Nmap offers options for specifying which ports are scanned and whether the scan order is randomized or sequential. By default, Nmap scans the most common 1,000 ports for each protocol. **-p** _port ranges_ (Only scan specified ports) This option specifies which ports you want to scan and overrides the default. Individual port numbers are OK, as are ranges separated by a hyphen (e.g. 1-1023). The beginning and/or end values of a range may be omitted, causing Nmap to use 1 and 65535, respectively. So you can specify **-p-** to scan ports from 1 through 65535. Scanning port zero is allowed if you specify it explicitly. For IP protocol scanning (**-sO**), this option specifies the protocol numbers you wish to scan for (0–255). When scanning a combination of protocols (e.g. TCP and UDP), you can specify a particular protocol by preceding the port numbers by T: for TCP, U: for UDP, S: for SCTP, or P: for IP Protocol. The qualifier lasts until you specify another qualifier. For example, the argument **-p** **U:53,111,137,T:21-25,80,139,8080** would scan UDP ports 53, 111,and 137, as well as the listed TCP ports. Note that to scan both UDP and TCP, you have to specify **-sU** and at least one TCP scan type (such as **-sS** , **-sF** , or **-sT**). If no protocol qualifier is given, the port numbers are added to all protocol lists. Ports can also be specified by name according to what the port is referred to in the nmap-services. You can even use the wildcards * and ? with the names. For example, to scan FTP and all ports whose names begin with “http”, use **-p** **ftp,http***. Be careful about shell expansions and quote the argument to **-p** if unsure. Ranges of ports can be surrounded by square brackets to indicate ports inside that range that appear in nmap-services. For example, the following will scan all ports in nmap-services equal to or below 1024: **-p [-1024]**. Be careful with shell expansions and quote the argument to **-p** if unsure. **--exclude-ports** _port ranges_ (Exclude the specified ports from scanning) This option specifies which ports you do want Nmap to exclude from scanning. The _port ranges_ are specified similar to **-p**. For IP protocol scanning (**-sO**), this option specifies the protocol numbers you wish to exclude (0–255). When ports are asked to be excluded, they are excluded from all types of scans (i.e. they will not be scanned under any circumstances). This also includes the discovery phase. **-F**(Fast (limited port) scan) Specifies that you wish to scan fewer ports than the default. Normally Nmap scans the most common 1,000 ports for each scanned protocol. With **-F** , this is reduced to 100. Nmap needs an nmap-services file with frequency information in order to know which ports are the most common. If port frequency information isn't available, perhaps because of the use of a custom nmap-services file, Nmap scans all named ports plus ports 1-1024. In that case, **-F** means to scan only ports that are named in the services file. **-r**(Don't randomize ports) By default, Nmap randomizes the scanned port order (except that certain commonly accessible ports are moved near the beginning for efficiency reasons). This randomization is normally desirable, but you can specify **-r** for sequential (sorted from lowest to highest) port scanning instead. **--port-ratio** _ratio_**< decimal number between 0 and 1>** Scans all ports in nmap-services file with a ratio greater than the one given. _ratio_ must be between 0.0 and 1.0. **--top-ports** _n_ Scans the _n_ highest-ratio ports found in nmap-services file after excluding all ports specified by **--exclude-ports**. _n_ must be 1 or greater. ## SERVICE AND VERSION DETECTION Point Nmap at a remote machine and it might tell you that ports 25/tcp, 80/tcp, and 53/udp are open. Using its nmap-services database of about 2,200 well-known services, Nmap would report that those ports probably correspond to a mail server (SMTP), web server (HTTP), and name server (DNS) respectively. This lookup is usually accurate—the vast majority of daemons listening on TCP port 25 are, in fact, mail servers. However, you should not bet your security on this! People can and do run services on strange ports. Even if Nmap is right, and the hypothetical server above is running SMTP, HTTP, and DNS servers, that is not a lot of information. When doing vulnerability assessments (or even simple network inventories) of your companies or clients, you really want to know which mail and DNS servers and versions are running. Having an accurate version number helps dramatically in determining which exploits a server is vulnerable to. Version detection helps you obtain this information. After TCP and/or UDP ports are discovered using one of the other scan methods, version detection interrogates those ports to determine more about what is actually running. The nmap-service-probes database contains probes for querying various services and match expressions to recognize and parse responses. Nmap tries to determine the service protocol (e.g. FTP, SSH, Telnet, HTTP), the application name (e.g. ISC BIND, Apache httpd, Solaris telnetd), the version number, hostname, device type (e.g. printer, router), the OS family (e.g. Windows, Linux). When possible, Nmap also gets the Common Platform Enumeration (CPE) representation of this information. Sometimes miscellaneous details like whether an X server is open to connections, the SSH protocol version, or the KaZaA user name, are available. Of course, most services don't provide all of this information. If Nmap was compiled with OpenSSL support, it will connect to SSL servers to deduce the service listening behind that encryption layer. Some UDP ports are left in the open|filtered state after a UDP port scan is unable to determine whether the port is open or filtered. Version detection will try to elicit a response from these ports (just as it does with open ports), and change the state to open if it succeeds. open|filtered TCP ports are treated the same way. Note that the Nmap **-A** option enables version detection among other things. A paper documenting the workings, usage, and customization of version detection is available at **https://nmap.org/book/vscan.html ******. When RPC services are discovered, the Nmap RPC grinder is automatically used to determine the RPC program and version numbers. It takes all the TCP/UDP ports detected as RPC and floods them with SunRPC program NULL commands in an attempt to determine whether they are RPC ports, and if so, what program and version number they serve up. Thus you can effectively obtain the same info as**rpcinfo -p** even if the target's portmapper is behind a firewall (or protected by TCP wrappers). Decoys do not currently work with RPC scan. When Nmap receives responses from a service but cannot match them to its database, it prints out a special fingerprint and a URL for you to submit it to if you know for sure what is running on the port. Please take a couple minutes to make the submission so that your find can benefit everyone. Thanks to these submissions, Nmap has about 6,500 pattern matches for more than 650 protocols such as SMTP, FTP, HTTP, etc. Version detection is enabled and controlled with the following options: **-sV**(Version detection) Enables version detection, as discussed above. Alternatively, you can use **-A** , which enables version detection among other things. **-sR** is an alias for **-sV**. Prior to March 2011, it was used to active the RPC grinder separately from version detection, but now these options are always combined. **--allports**(Don't exclude any ports from version detection) By default, Nmap version detection skips TCP port 9100 because some printers simply print anything sent to that port, leading to dozens of pages of HTTP GET requests, binary SSL session requests, etc. This behavior can be changed by modifying or removing the Exclude directive in nmap-service-probes, or you can specify **--allports** to scan all ports regardless of any Exclude directive. **--version-intensity** _intensity_ (Set version scan intensity) When performing a version scan (**-sV**), Nmap sends a series of probes, each of which is assigned a rarity value between one and nine. The lower-numbered probes are effective against a wide variety of common services, while the higher-numbered ones are rarely useful. The intensity level specifies which probes should be applied. The higher the number, the more likely it is the service will be correctly identified. However, high intensity scans take longer. The intensity must be between 0 and 9. The default is 7. When a probe is registered to the target port via the nmap-service-probes ports directive, that probe is tried regardless of intensity level. This ensures that the DNS probes will always be attempted against any open port 53, the SSL probe will be done against 443, etc. **--version-light**(Enable light mode) This is a convenience alias for **--version-intensity 2**. This light mode makes version scanning much faster, but it is slightly less likely to identify services. **--version-all**(Try every single probe) An alias for **--version-intensity 9** , ensuring that every single probe is attempted against each port. **--version-trace**(Trace version scan activity) This causes Nmap to print out extensive debugging info about what version scanning is doing. It is a subset of what you get with **--packet-trace**. ## OS DETECTION One of Nmap's best-known features is remote OS detection using TCP/IP stack fingerprinting. Nmap sends a series of TCP and UDP packets to the remote host and examines practically every bit in the responses. After performing dozens of tests such as TCP ISN sampling, TCP options support and ordering, IP ID sampling, and the initial window size check, Nmap compares the results to its nmap-os-db database of more than 2,600 known OS fingerprints and prints out the OS details if there is a match. Each fingerprint includes a freeform textual description of the OS, and a classification which provides the vendor name (e.g. Sun), underlying OS (e.g. Solaris), OS generation (e.g. 10), and device type (general purpose, router, switch, game console, etc). Most fingerprints also have a Common Platform Enumeration (CPE) representation, like cpe:/o:linux:linux_kernel:2.6. If Nmap is unable to guess the OS of a machine, and conditions are good (e.g. at least one open port and one closed port were found), Nmap will provide a URL you can use to submit the fingerprint if you know (for sure) the OS running on the machine. By doing this you contribute to the pool of operating systems known to Nmap and thus it will be more accurate for everyone. OS detection enables some other tests which make use of information that is gathered during the process anyway. One of these is TCP Sequence Predictability Classification. This measures approximately how hard it is to establish a forged TCP connection against the remote host. It is useful for exploiting source-IP based trust relationships (rlogin, firewall filters, etc) or for hiding the source of an attack. This sort of spoofing is rarely performed any more, but many machines are still vulnerable to it. The actual difficulty number is based on statistical sampling and may fluctuate. It is generally better to use the English classification such as “worthy challenge” or “trivial joke”. This is only reported in normal output in verbose (**-v**) mode. When verbose mode is enabled along with **-O** , IP ID sequence generation is also reported. Most machines are in the “incremental” class, which means that they increment the ID field in the IP header for each packet they send. This makes them vulnerable to several advanced information gathering and spoofing attacks. Another bit of extra information enabled by OS detection is a guess at a target's uptime. This uses the TCP timestamp option (**RFC 1323******[9]) to guess when a machine was last rebooted. The guess can be inaccurate due to the timestamp counter not being initialized to zero or the counter overflowing and wrapping around, so it is printed only in verbose mode. A paper documenting the workings, usage, and customization of OS detection is available at**https://nmap.org/book/osdetect.html ******. OS detection is enabled and controlled with the following options:**-O**(Enable OS detection) Enables OS detection, as discussed above. Alternatively, you can use **-A** to enable OS detection along with other things. **--osscan-limit**(Limit OS detection to promising targets) OS detection is far more effective if at least one open and one closed TCP port are found. Set this option and Nmap will not even try OS detection against hosts that do not meet this criteria. This can save substantial time, particularly on **-Pn** scans against many hosts. It only matters when OS detection is requested with **-O** or **-A**. **--osscan-guess** ; **--fuzzy**(Guess OS detection results) When Nmap is unable to detect a perfect OS match, it sometimes offers up near-matches as possibilities. The match has to be very close for Nmap to do this by default. Either of these (equivalent) options make Nmap guess more aggressively. Nmap will still tell you when an imperfect match is printed and display its confidence level (percentage) for each guess. **--max-os-tries**(Set the maximum number of OS detection tries against a target) When Nmap performs OS detection against a target and fails to find a perfect match, it usually repeats the attempt. By default, Nmap tries five times if conditions are favorable for OS fingerprint submission, and twice when conditions aren't so good. Specifying a lower **--max-os-tries** value (such as 1) speeds Nmap up, though you miss out on retries which could potentially identify the OS. Alternatively, a high value may be set to allow even more retries when conditions are favorable. This is rarely done, except to generate better fingerprints for submission and integration into the Nmap OS database. ## NMAP SCRIPTING ENGINE (NSE) The Nmap Scripting Engine (NSE) is one of Nmap's most powerful and flexible features. It allows users to write (and share) simple scripts (using the **Lua programming language******[10] ) to automate a wide variety of networking tasks. Those scripts are executed in parallel with the speed and efficiency you expect from Nmap. Users can rely on the growing and diverse set of scripts distributed with Nmap, or write their own to meet custom needs. Tasks we had in mind when creating the system include network discovery, more sophisticated version detection, vulnerability detection. NSE can even be used for vulnerability exploitation. To reflect those different uses and to simplify the choice of which scripts to run, each script contains a field associating it with one or more categories. Currently defined categories are auth, broadcast, default. discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln. These are all described at**https://nmap.org/book/nse-usage.html#nse-categories ******. Scripts are not run in a sandbox and thus could accidentally or maliciously damage your system or invade your privacy. Never run scripts from third parties unless you trust the authors or have carefully audited the scripts yourself. The Nmap Scripting Engine is described in detail at**https://nmap.org/book/nse.html ** and is controlled by the following options: **-sC** Performs a script scan using the default set of scripts. It is equivalent to **--script=default**. Some of the scripts in this category are considered intrusive and should not be run against a target network without permission. Note that this shorthand option is ignored whenever at least one **--script** is also specified. **--script** _filename_**|**_category_**|**_directory_**/|**_expression_**[,...]** Runs a script scan using the comma-separated list of filenames, script categories, and directories. Each element in the list may also be a Boolean expression describing a more complex set of scripts. Each element is interpreted first as an expression, then as a category, and finally as a file or directory name. There are two special features for advanced users only. One is to prefix script names and expressions with + to force them to run even if they normally wouldn't (e.g. the relevant service wasn't detected on the target port). The other is that the argument all may be used to specify every script in Nmap's database. Be cautious with this because NSE contains dangerous scripts such as exploits, brute force authentication crackers, and denial of service attacks. File and directory names may be relative or absolute. Absolute names are used directly. Relative paths are looked for in the scripts of each of the following places until found: **--datadir** **$NMAPDIR** ~/.nmap (not searched on Windows) _APPDATA_ \nmap (only on Windows) the directory containing the nmap executable the directory containing the nmap executable, followed by ../share/nmap (not searched on Windows) _NMAPDATADIR_ (not searched on Windows) the current directory. When a directory name ending in / is given, Nmap loads every file in the directory whose name ends with .nse. All other files are ignored and directories are not searched recursively. When a filename is given, it does not have to have the .nse extension; it will be added automatically if necessary. Nmap scripts are stored in a scripts subdirectory of the Nmap data directory by default (see **https://nmap.org/book/data-files.html ******). For efficiency, scripts are indexed in a database stored in scripts/script.db, which lists the category or categories in which each script belongs. When referring to scripts from script.db by name, you can use a shell-style ‘*’ wildcard.**nmap --script "http-*"** Loads all scripts whose name starts with http-, such as http-auth and http-open-proxy. The argument to **--script** had to be in quotes to protect the wildcard from the shell. More complicated script selection can be done using the and, or, and not operators to build Boolean expressions. The operators have the same **precedence******[11] as in Lua: not is the highest, followed by and and then or. You can alter precedence by using parentheses. Because expressions contain space characters it is necessary to quote them.**nmap --script "not intrusive"** Loads every script except for those in the intrusive category. **nmap --script "default or safe"** This is functionally equivalent to **nmap --script** **"default,safe"**. It loads all scripts that are in the default category or the safe category or both. **nmap --script "default and safe"** Loads those scripts that are in _both_ the default and safe categories. **nmap --script "(default or safe or intrusive) and not http-*"** Loads scripts in the default, safe, or intrusive categories, except for those whose names start with http-. **--script-args** _n1_**=**_v1_**,**_n2_**={**_n3_**=**_v3_**},**_n4_**={**_v4_**,**_v5_**}** Lets you provide arguments to NSE scripts. Arguments are a comma-separated list of name=value pairs. Names and values may be strings not containing whitespace or the characters ‘{’, ‘}’, ‘=’, or ‘,’. To include one of these characters in a string, enclose the string in single or double quotes. Within a quoted string, ‘\’ escapes a quote. A backslash is only used to escape quotation marks in this special case; in all other cases a backslash is interpreted literally. Values may also be tables enclosed in {}, just as in Lua. A table may contain simple string values or more name-value pairs, including nested tables. Many scripts qualify their arguments with the script name, as in xmpp-info.server_name. You may use that full qualified version to affect just the specified script, or you may pass the unqualified version (server_name in this case) to affect all scripts using that argument name. A script will first check for its fully qualified argument name (the name specified in its documentation) before it accepts an unqualified argument name. A complex example of script arguments is **--script-args** **'user=foo,pass=",{}=bar",whois={whodb=nofollow+ripe},xmpp-info.server_name=localhost'**. The online NSE Documentation Portal at **https://nmap.org/nsedoc/******lists the arguments that each script accepts.**--script-args-file** _filename_ Lets you load arguments to NSE scripts from a file. Any arguments on the command line supersede ones in the file. The file can be an absolute path, or a path relative to Nmap's usual search path (NMAPDIR, etc.) Arguments can be comma-separated or newline-separated, but otherwise follow the same rules as for **--script-args** , without requiring special quoting and escaping, since they are not parsed by the shell. **--script-help** _filename_**|**_category_**|**_directory_**|**_expression_**|all[,...]** Shows help about scripts. For each script matching the given specification, Nmap prints the script name, its categories, and its description. The specifications are the same as those accepted by **--script** ; so for example if you want help about the ftp-anon script, you would run **nmap --script-help** **ftp-anon**. In addition to getting help for individual scripts, you can use this as a preview of what scripts will be run for a specification, for example with **nmap --script-help default**. **--script-trace** This option does what **--packet-trace** does, just one ISO layer higher. If this option is specified all incoming and outgoing communication performed by a script is printed. The displayed information includes the communication protocol, the source, the target and the transmitted data. If more than 5% of all transmitted data is not printable, then the trace output is in a hex dump format. Specifying **--packet-trace** enables script tracing too. **--script-updatedb** This option updates the script database found in scripts/script.db which is used by Nmap to determine the available default scripts and categories. It is only necessary to update the database if you have added or removed NSE scripts from the default scripts directory or if you have changed the categories of any script. This option is generally used by itself: **nmap --script-updatedb**. ## TIMING AND PERFORMANCE One of my highest Nmap development priorities has always been performance. A default scan (**nmap** _hostname_) of a host on my local network takes a fifth of a second. That is barely enough time to blink, but adds up when you are scanning hundreds or thousands of hosts. Moreover, certain scan options such as UDP scanning and version detection can increase scan times substantially. So can certain firewall configurations, particularly response rate limiting. While Nmap utilizes parallelism and many advanced algorithms to accelerate these scans, the user has ultimate control over how Nmap runs. Expert users carefully craft Nmap commands to obtain only the information they care about while meeting their time constraints. Techniques for improving scan times include omitting non-critical tests, and upgrading to the latest version of Nmap (performance enhancements are made frequently). Optimizing timing parameters can also make a substantial difference. Those options are listed below. Some options accept a time parameter. This is specified in seconds by default, though you can append ‘ms’, ‘s’, ‘m’, or ‘h’ to the value to specify milliseconds, seconds, minutes, or hours. So the **--host-timeout** arguments 900000ms, 900, 900s, and 15m all do the same thing. **--min-hostgroup** _numhosts_ ; **--max-hostgroup** _numhosts_ (Adjust parallel scan group sizes) Nmap has the ability to port scan or version scan multiple hosts in parallel. Nmap does this by dividing the target IP space into groups and then scanning one group at a time. In general, larger groups are more efficient. The downside is that host results can't be provided until the whole group is finished. So if Nmap started out with a group size of 50, the user would not receive any reports (except for the updates offered in verbose mode) until the first 50 hosts are completed. By default, Nmap takes a compromise approach to this conflict. It starts out with a group size as low as five so the first results come quickly and then increases the groupsize to as high as 1024. The exact default numbers depend on the options given. For efficiency reasons, Nmap uses larger group sizes for UDP or few-port TCP scans. When a maximum group size is specified with **--max-hostgroup** , Nmap will never exceed that size. Specify a minimum size with **--min-hostgroup** and Nmap will try to keep group sizes above that level. Nmap may have to use smaller groups than you specify if there are not enough target hosts left on a given interface to fulfill the specified minimum. Both may be set to keep the group size within a specific range, though this is rarely desired. These options do not have an effect during the host discovery phase of a scan. This includes plain ping scans (**-sn**). Host discovery always works in large groups of hosts to improve speed and accuracy. The primary use of these options is to specify a large minimum group size so that the full scan runs more quickly. A common choice is 256 to scan a network in /24 sized chunks. For a scan with many ports, exceeding that number is unlikely to help much. For scans of just a few port numbers, host group sizes of 2048 or more may be helpful. **--min-parallelism** _numprobes_ ; **--max-parallelism** _numprobes_ (Adjust probe parallelization) These options control the total number of probes that may be outstanding for a host group. They are used for port scanning and host discovery. By default, Nmap calculates an ever-changing ideal parallelism based on network performance. If packets are being dropped, Nmap slows down and allows fewer outstanding probes. The ideal probe number slowly rises as the network proves itself worthy. These options place minimum or maximum bounds on that variable. By default, the ideal parallelism can drop to one if the network proves unreliable and rise to several hundred in perfect conditions. The most common usage is to set **--min-parallelism** to a number higher than one to speed up scans of poorly performing hosts or networks. This is a risky option to play with, as setting it too high may affect accuracy. Setting this also reduces Nmap's ability to control parallelism dynamically based on network conditions. A value of 10 might be reasonable, though I only adjust this value as a last resort. The **--max-parallelism** option is sometimes set to one to prevent Nmap from sending more than one probe at a time to hosts. The **--scan-delay** option, discussed later, is another way to do this. **--min-rtt-timeout** _time_ , **--max-rtt-timeout** _time_ , **--initial-rtt-timeout** _time_ (Adjust probe timeouts) Nmap maintains a running timeout value for determining how long it will wait for a probe response before giving up or retransmitting the probe. This is calculated based on the response times of previous probes. If the network latency shows itself to be significant and variable, this timeout can grow to several seconds. It also starts at a conservative (high) level and may stay that way for a while when Nmap scans unresponsive hosts. Specifying a lower **--max-rtt-timeout** and **--initial-rtt-timeout** than the defaults can cut scan times significantly. This is particularly true for pingless (**-Pn**) scans, and those against heavily filtered networks. Don't get too aggressive though. The scan can end up taking longer if you specify such a low value that many probes are timing out and retransmitting while the response is in transit. If all the hosts are on a local network, 100 milliseconds (**--max-rtt-timeout 100ms**) is a reasonable aggressive value. If routing is involved, ping a host on the network first with the ICMP ping utility, or with a custom packet crafter such as Nping that is more likely to get through a firewall. Look at the maximum round trip time out of ten packets or so. You might want to double that for the **--initial-rtt-timeout** and triple or quadruple it for the **--max-rtt-timeout**. I generally do not set the maximum RTT below 100 ms, no matter what the ping times are. Nor do I exceed 1000 ms. **--min-rtt-timeout** is a rarely used option that could be useful when a network is so unreliable that even Nmap's default is too aggressive. Since Nmap only reduces the timeout down to the minimum when the network seems to be reliable, this need is unusual and should be reported as a bug to the nmap-dev mailing list. **--max-retries** _numtries_ (Specify the maximum number of port scan probe retransmissions) When Nmap receives no response to a port scan probe, it could mean the port is filtered. Or maybe the probe or response was simply lost on the network. It is also possible that the target host has rate limiting enabled that temporarily blocked the response. So Nmap tries again by retransmitting the initial probe. If Nmap detects poor network reliability, it may try many more times before giving up on a port. While this benefits accuracy, it also lengthens scan times. When performance is critical, scans may be sped up by limiting the number of retransmissions allowed. You can even specify **--max-retries 0** to prevent any retransmissions, though that is only recommended for situations such as informal surveys where occasional missed ports and hosts are acceptable. The default (with no **-T** template) is to allow ten retransmissions. If a network seems reliable and the target hosts aren't rate limiting, Nmap usually only does one retransmission. So most target scans aren't even affected by dropping **--max-retries** to a low value such as three. Such values can substantially speed scans of slow (rate limited) hosts. You usually lose some information when Nmap gives up on ports early, though that may be preferable to letting the **--host-timeout** expire and losing all information about the target. **--host-timeout** _time_ (Give up on slow target hosts) Some hosts simply take a _long_ time to scan. This may be due to poorly performing or unreliable networking hardware or software, packet rate limiting, or a restrictive firewall. The slowest few percent of the scanned hosts can eat up a majority of the scan time. Sometimes it is best to cut your losses and skip those hosts initially. Specify **--host-timeout** with the maximum amount of time you are willing to wait. For example, specify 30m to ensure that Nmap doesn't waste more than half an hour on a single host. Note that Nmap may be scanning other hosts at the same time during that half an hour, so it isn't a complete loss. A host that times out is skipped. No port table, OS detection, or version detection results are printed for that host. The special value 0 can be used to mean “no timeout”, which can be used to override the **T5** timing template, which sets the host timeout to 15 minutes. **--script-timeout** _time_ While some scripts complete in fractions of a second, others can take hours or more depending on the nature of the script, arguments passed in, network and application conditions, and more. The **--script-timeout** option sets a ceiling on script execution time. Any script instance which exceeds that time will be terminated and no output will be shown. If debugging (**-d**) is enabled, Nmap will report on each timeout. For host and service scripts, a script instance only scans a single target host or port and the timeout period will be reset for the next instance. The special value 0 can be used to mean “no timeout”, which can be used to override the **T5** timing template, which sets the script timeout to 10 minutes. **--scan-delay** _time_ ; **--max-scan-delay** _time_ (Adjust delay between probes) This option causes Nmap to wait at least the given amount of time between each probe it sends to a given host. This is particularly useful in the case of rate limiting. Solaris machines (among many others) will usually respond to UDP scan probe packets with only one ICMP message per second. Any more than that sent by Nmap will be wasteful. A **--scan-delay** of 1s will keep Nmap at that slow rate. Nmap tries to detect rate limiting and adjust the scan delay accordingly, but it doesn't hurt to specify it explicitly if you already know what rate works best. When Nmap adjusts the scan delay upward to cope with rate limiting, the scan slows down dramatically. The **--max-scan-delay** option specifies the largest delay that Nmap will allow. A low **--max-scan-delay** can speed up Nmap, but it is risky. Setting this value too low can lead to wasteful packet retransmissions and possible missed ports when the target implements strict rate limiting. Another use of **--scan-delay** is to evade threshold based intrusion detection and prevention systems (IDS/IPS). **--min-rate** _number_ ; **--max-rate** _number_ (Directly control the scanning rate) Nmap's dynamic timing does a good job of finding an appropriate speed at which to scan. Sometimes, however, you may happen to know an appropriate scanning rate for a network, or you may have to guarantee that a scan will be finished by a certain time. Or perhaps you must keep Nmap from scanning too quickly. The **--min-rate** and **--max-rate** options are designed for these situations. When the **--min-rate** option is given Nmap will do its best to send packets as fast as or faster than the given rate. The argument is a positive real number representing a packet rate in packets per second. For example, specifying **--min-rate 300** means that Nmap will try to keep the sending rate at or above 300 packets per second. Specifying a minimum rate does not keep Nmap from going faster if conditions warrant. Likewise, **--max-rate** limits a scan's sending rate to a given maximum. Use **--max-rate 100** , for example, to limit sending to 100 packets per second on a fast network. Use **--max-rate 0.1** for a slow scan of one packet every ten seconds. Use **--min-rate** and **--max-rate** together to keep the rate inside a certain range. These two options are global, affecting an entire scan, not individual hosts. They only affect port scans and host discovery scans. Other features like OS detection implement their own timing. There are two conditions when the actual scanning rate may fall below the requested minimum. The first is if the minimum is faster than the fastest rate at which Nmap can send, which is dependent on hardware. In this case Nmap will simply send packets as fast as possible, but be aware that such high rates are likely to cause a loss of accuracy. The second case is when Nmap has nothing to send, for example at the end of a scan when the last probes have been sent and Nmap is waiting for them to time out or be responded to. It's normal to see the scanning rate drop at the end of a scan or in between hostgroups. The sending rate may temporarily exceed the maximum to make up for unpredictable delays, but on average the rate will stay at or below the maximum. Specifying a minimum rate should be done with care. Scanning faster than a network can support may lead to a loss of accuracy. In some cases, using a faster rate can make a scan take _longer_ than it would with a slower rate. This is because Nmap's adaptive retransmission algorithms will detect the network congestion caused by an excessive scanning rate and increase the number of retransmissions in order to improve accuracy. So even though packets are sent at a higher rate, more packets are sent overall. Cap the number of retransmissions with the **--max-retries** option if you need to set an upper limit on total scan time. **--defeat-rst-ratelimit** Many hosts have long used rate limiting to reduce the number of ICMP error messages (such as port-unreachable errors) they send. Some systems now apply similar rate limits to the RST (reset) packets they generate. This can slow Nmap down dramatically as it adjusts its timing to reflect those rate limits. You can tell Nmap to ignore those rate limits (for port scans such as SYN scan which _don't_ treat non-responsive ports as open) by specifying **--defeat-rst-ratelimit**. Using this option can reduce accuracy, as some ports will appear non-responsive because Nmap didn't wait long enough for a rate-limited RST response. With a SYN scan, the non-response results in the port being labeled filtered rather than the closed state we see when RST packets are received. This option is useful when you only care about open ports, and distinguishing between closed and filtered ports isn't worth the extra time. **--defeat-icmp-ratelimit** Similar to **--defeat-rst-ratelimit** , the **--defeat-icmp-ratelimit** option trades accuracy for speed, increasing UDP scanning speed against hosts that rate-limit ICMP error messages. Because this option causes Nmap to not delay in order to receive the port unreachable messages, a non-responsive port will be labeled closed|filtered instead of the default open|filtered. This has the effect of only treating ports which actually respond via UDP as open. Since many UDP services do not respond in this way, the chance for inaccuracy is greater with this option than with **--defeat-rst-ratelimit**. **--nsock-engine iocp|epoll|kqueue|poll|select** Enforce use of a given nsock IO multiplexing engine. Only the select(2)-based fallback engine is guaranteed to be available on your system. Engines are named after the name of the IO management facility they leverage. Engines currently implemented are epoll, kqueue, poll, and select, but not all will be present on any platform. By default, Nmap will use the "best" engine, i.e. the first one in this list that is supported. Use **nmap -V** to see which engines are supported on your platform. **-T paranoid|sneaky|polite|normal|aggressive|insane**(Set a timing template) While the fine-grained timing controls discussed in the previous section are powerful and effective, some people find them confusing. Moreover, choosing the appropriate values can sometimes take more time than the scan you are trying to optimize. Fortunately, Nmap offers a simpler approach, with six timing templates. You can specify them with the **-T** option and their number (0–5) or their name. The template names are **paranoid**(**0**), **sneaky**(**1**), **polite**(**2**), **normal**(**3**), **aggressive**(**4**), and **insane**(**5**). The first two are for IDS evasion. Polite mode slows down the scan to use less bandwidth and target machine resources. Normal mode is the default and so **-T3** does nothing. Aggressive mode speeds scans up by making the assumption that you are on a reasonably fast and reliable network. Finally insane mode assumes that you are on an extraordinarily fast network or are willing to sacrifice some accuracy for speed. These templates allow the user to specify how aggressive they wish to be, while leaving Nmap to pick the exact timing values. The templates also make some minor speed adjustments for which fine-grained control options do not currently exist. For example, **-T4** prohibits the dynamic scan delay from exceeding 10 ms for TCP ports and **-T5** caps that value at 5 ms. Templates can be used in combination with fine-grained controls, and the fine-grained controls that you specify will take precedence over the timing template default for that parameter. I recommend using **-T4** when scanning reasonably modern and reliable networks. Keep that option even when you add fine-grained controls so that you benefit from those extra minor optimizations that it enables. If you are on a decent broadband or ethernet connection, I would recommend always using **-T4**. Some people love **-T5** though it is too aggressive for my taste. People sometimes specify **-T2** because they think it is less likely to crash hosts or because they consider themselves to be polite in general. They often don't realize just how slow **-T polite** really is. Their scan may take ten times longer than a default scan. Machine crashes and bandwidth problems are rare with the default timing options (**-T3**) and so I normally recommend that for cautious scanners. Omitting version detection is far more effective than playing with timing values at reducing these problems. While **-T0** and **-T1** may be useful for avoiding IDS alerts, they will take an extraordinarily long time to scan thousands of machines or ports. For such a long scan, you may prefer to set the exact timing values you need rather than rely on the canned **-T0** and **-T1** values. The main effects of **T0** are serializing the scan so only one port is scanned at a time, and waiting five minutes between sending each probe. **T1** and **T2** are similar but they only wait 15 seconds and 0.4 seconds, respectively, between probes. **T3** is Nmap's default behavior, which includes parallelization. **-T4** does the equivalent of **--max-rtt-timeout 1250ms --min-rtt-timeout 100ms** **--initial-rtt-timeout 500ms --max-retries 6** and sets the maximum TCP and SCTP scan delay to 10ms. **T5** does the equivalent of **--max-rtt-timeout 300ms --min-rtt-timeout 50ms** **--initial-rtt-timeout 250ms --max-retries 2 --host-timeout 15m** **--script-timeout 10m** as well as setting the maximum TCP and SCTP scan delay to 5ms. Maximum UDP scan delay is not set by **T4** or **T5** , but it can be set with the **--max-scan-delay** option. ## FIREWALL/IDS EVASION AND SPOOFING Many Internet pioneers envisioned a global open network with a universal IP address space allowing virtual connections between any two nodes. This allows hosts to act as true peers, serving and retrieving information from each other. People could access all of their home systems from work, changing the climate control settings or unlocking the doors for early guests. This vision of universal connectivity has been stifled by address space shortages and security concerns. In the early 1990s, organizations began deploying firewalls for the express purpose of reducing connectivity. Huge networks were cordoned off from the unfiltered Internet by application proxies, network address translation, and packet filters. The unrestricted flow of information gave way to tight regulation of approved communication channels and the content that passes over them. Network obstructions such as firewalls can make mapping a network exceedingly difficult. It will not get any easier, as stifling casual reconnaissance is often a key goal of implementing the devices. Nevertheless, Nmap offers many features to help understand these complex networks, and to verify that filters are working as intended. It even supports mechanisms for bypassing poorly implemented defenses. One of the best methods of understanding your network security posture is to try to defeat it. Place yourself in the mind-set of an attacker, and deploy techniques from this section against your networks. Launch an FTP bounce scan, idle scan, fragmentation attack, or try to tunnel through one of your own proxies. In addition to restricting network activity, companies are increasingly monitoring traffic with intrusion detection systems (IDS). All of the major IDSs ship with rules designed to detect Nmap scans because scans are sometimes a precursor to attacks. Many of these products have recently morphed into intrusion _prevention_ systems (IPS) that actively block traffic deemed malicious. Unfortunately for network administrators and IDS vendors, reliably detecting bad intentions by analyzing packet data is a tough problem. Attackers with patience, skill, and the help of certain Nmap options can usually pass by IDSs undetected. Meanwhile, administrators must cope with large numbers of false positive results where innocent activity is misdiagnosed and alerted on or blocked. Occasionally people suggest that Nmap should not offer features for evading firewall rules or sneaking past IDSs. They argue that these features are just as likely to be misused by attackers as used by administrators to enhance security. The problem with this logic is that these methods would still be used by attackers, who would just find other tools or patch the functionality into Nmap. Meanwhile, administrators would find it that much harder to do their jobs. Deploying only modern, patched FTP servers is a far more powerful defense than trying to prevent the distribution of tools implementing the FTP bounce attack. There is no magic bullet (or Nmap option) for detecting and subverting firewalls and IDS systems. It takes skill and experience. A tutorial is beyond the scope of this reference guide, which only lists the relevant options and describes what they do. **-f**(fragment packets); **--mtu**(using the specified MTU) The **-f** option causes the requested scan (including host discovery scans) to use tiny fragmented IP packets. The idea is to split up the TCP header over several packets to make it harder for packet filters, intrusion detection systems, and other annoyances to detect what you are doing. Be careful with this! Some programs have trouble handling these tiny packets. The old-school sniffer named Sniffit segmentation faulted immediately upon receiving the first fragment. Specify this option once, and Nmap splits the packets into eight bytes or less after the IP header. So a 20-byte TCP header would be split into three packets. Two with eight bytes of the TCP header, and one with the final four. Of course each fragment also has an IP header. Specify **-f** again to use 16 bytes per fragment (reducing the number of fragments). Or you can specify your own offset size with the **--mtu** option. Don't also specify **-f** if you use **--mtu**. The offset must be a multiple of eight. While fragmented packets won't get by packet filters and firewalls that queue all IP fragments, such as the _CONFIG_IP_ALWAYS_DEFRAG_ option in the Linux kernel, some networks can't afford the performance hit this causes and thus leave it disabled. Others can't enable this because fragments may take different routes into their networks. Some source systems defragment outgoing packets in the kernel. Linux with the iptables connection tracking module is one such example. Do a scan while a sniffer such as Wireshark is running to ensure that sent packets are fragmented. If your host OS is causing problems, try the **--send-eth** option to bypass the IP layer and send raw ethernet frames. Fragmentation is only supported for Nmap's raw packet features, which includes TCP and UDP port scans (except connect scan and FTP bounce scan) and OS detection. Features such as version detection and the Nmap Scripting Engine generally don't support fragmentation because they rely on your host's TCP stack to communicate with target services. **-D** _decoy1_**[,**_decoy2_]**[,ME][,...]**(Cloak a scan with decoys) Causes a decoy scan to be performed, which makes it appear to the remote host that the host(s) you specify as decoys are scanning the target network too. Thus their IDS might report 5–10 port scans from unique IP addresses, but they won't know which IP was scanning them and which were innocent decoys. While this can be defeated through router path tracing, response-dropping, and other active mechanisms, it is generally an effective technique for hiding your IP address. Separate each decoy host with commas, and you can optionally use ME as one of the decoys to represent the position for your real IP address. If you put ME in the sixth position or later, some common port scan detectors (such as Solar Designer's excellent Scanlogd) are unlikely to show your IP address at all. If you don't use ME, Nmap will put you in a random position. You can also use RND to generate a random, non-reserved IP address, or RND:_number_ to generate _number_ addresses. Note that the hosts you use as decoys should be up or you might accidentally SYN flood your targets. Also it will be pretty easy to determine which host is scanning if only one is actually up on the network. You might want to use IP addresses instead of names (so the decoy networks don't see you in their nameserver logs). Right now random IP address generation is only supported with IPv4 Decoys are used both in the initial host discovery scan (using ICMP, SYN, ACK, or whatever) and during the actual port scanning phase. Decoys are also used during remote OS detection (**-O**). Decoys do not work with version detection or TCP connect scan. When a scan delay is in effect, the delay is enforced between each batch of spoofed probes, not between each individual probe. Because decoys are sent as a batch all at once, they may temporarily violate congestion control limits. It is worth noting that using too many decoys may slow your scan and potentially even make it less accurate. Also, some ISPs will filter out your spoofed packets, but many do not restrict spoofed IP packets at all. **-S** _IP_Address_ (Spoof source address) In some circumstances, Nmap may not be able to determine your source address (Nmap will tell you if this is the case). In this situation, use **-S** with the IP address of the interface you wish to send packets through. Another possible use of this flag is to spoof the scan to make the targets think that _someone else_ is scanning them. Imagine a company being repeatedly port scanned by a competitor! The **-e** option and **-Pn** are generally required for this sort of usage. Note that you usually won't receive reply packets back (they will be addressed to the IP you are spoofing), so Nmap won't produce useful reports. **-e** _interface_ (Use specified interface) Tells Nmap what interface to send and receive packets on. Nmap should be able to detect this automatically, but it will tell you if it cannot. **--source-port** _portnumber_**; -g** _portnumber_ (Spoof source port number) One surprisingly common misconfiguration is to trust traffic based only on the source port number. It is easy to understand how this comes about. An administrator will set up a shiny new firewall, only to be flooded with complaints from ungrateful users whose applications stopped working. In particular, DNS may be broken because the UDP DNS replies from external servers can no longer enter the network. FTP is another common example. In active FTP transfers, the remote server tries to establish a connection back to the client to transfer the requested file. Secure solutions to these problems exist, often in the form of application-level proxies or protocol-parsing firewall modules. Unfortunately there are also easier, insecure solutions. Noting that DNS replies come from port 53 and active FTP from port 20, many administrators have fallen into the trap of simply allowing incoming traffic from those ports. They often assume that no attacker would notice and exploit such firewall holes. In other cases, administrators consider this a short-term stop-gap measure until they can implement a more secure solution. Then they forget the security upgrade. Overworked network administrators are not the only ones to fall into this trap. Numerous products have shipped with these insecure rules. Even Microsoft has been guilty. The IPsec filters that shipped with Windows 2000 and Windows XP contain an implicit rule that allows all TCP or UDP traffic from port 88 (Kerberos). In another well-known case, versions of the Zone Alarm personal firewall up to 2.1.25 allowed any incoming UDP packets with the source port 53 (DNS) or 67 (DHCP). Nmap offers the **-g** and **--source-port** options (they are equivalent) to exploit these weaknesses. Simply provide a port number and Nmap will send packets from that port where possible. Most scanning operations that use raw sockets, including SYN and UDP scans, support the option completely. The option notably doesn't have an effect for any operations that use normal operating system sockets, including DNS requests, TCP **connect** scan, version detection, and script scanning. Setting the source port also doesn't work for OS detection, because Nmap must use different port numbers for certain OS detection tests to work properly. **--data** _hex string_ (Append custom binary data to sent packets) This option lets you include binary data as payload in sent packets. _hex string_ may be specified in any of the following formats: 0xAABBCCDDEEFF _..._ , AABBCCDDEEFF _..._ or \xAA\xBB\xCC\xDD\xEE\xFF _..._. Examples of use are **--data** **0xdeadbeef** and **--data \xCA\xFE\x09**. Note that if you specify a number like 0x00ff no byte-order conversion is performed. Make sure you specify the information in the byte order expected by the receiver. **--data-string** _string_ (Append custom string to sent packets) This option lets you include a regular string as payload in sent packets. _string_ can contain any string. However, note that some characters may depend on your system's locale and the receiver may not see the same information. Also, make sure you enclose the string in double quotes and escape any special characters from the shell. Examples: **--data-string "Scan** **conducted by Security Ops, extension 7192"** or **--data-string** **"Ph34r my l33t skills"**. Keep in mind that nobody is likely to actually see any comments left by this option unless they are carefully monitoring the network with a sniffer or custom IDS rules. **--data-length** _number_ (Append random data to sent packets) Normally Nmap sends minimalist packets containing only a header. So its TCP packets are generally 40 bytes and ICMP echo requests are just 28. Some UDP ports and IP protocols get a custom payload by default. This option tells Nmap to append the given number of random bytes to most of the packets it sends, and not to use any protocol-specific payloads. (Use **--data-length 0** for no random or protocol-specific payloads.) OS detection (**-O**) packets are not affected because accuracy there requires probe consistency, but most pinging and portscan packets support this. It slows things down a little, but can make a scan slightly less conspicuous. **--ip-options** _R|S [route]|L [route]|T|U ..._ **; --ip-options** _hex_ _string_ (Send packets with specified ip options) The **IP protocol******[12] offers several options which may be placed in packet headers. Unlike the ubiquitous TCP options, IP options are rarely seen due to practicality and security concerns. In fact, many Internet routers block the most dangerous options such as source routing. Yet options can still be useful in some cases for determining and manipulating the network route to target machines. For example, you may be able to use the record route option to determine a path to a target even when more traditional traceroute-style approaches fail. Or if your packets are being dropped by a certain firewall, you may be able to specify a different route with the strict or loose source routing options. The most powerful way to specify IP options is to simply pass in values as the argument to**--ip-options**. Precede each hex number with \x then the two digits. You may repeat certain characters by following them with an asterisk and then the number of times you wish them to repeat. For example, \x01\x07\x04\x00*36\x01 is a hex string containing 36 NUL bytes. Nmap also offers a shortcut mechanism for specifying options. Simply pass the letter R, T, or U to request record-route, record-timestamp, or both options together, respectively. Loose or strict source routing may be specified with an L or S followed by a space and then a space-separated list of IP addresses. If you wish to see the options in packets sent and received, specify **--packet-trace**. For more information and examples of using IP options with Nmap, see **https://seclists.org/nmap-dev/2006/q3/52 ******.**--ttl** _value_ (Set IP time-to-live field) Sets the IPv4 time-to-live field in sent packets to the given value. **--randomize-hosts**(Randomize target host order) Tells Nmap to shuffle each group of up to 16384 hosts before it scans them. This can make the scans less obvious to various network monitoring systems, especially when you combine it with slow timing options. If you want to randomize over larger group sizes, increase _PING_GROUP_SZ_ in nmap.h and recompile. An alternative solution is to generate the target IP list with a list scan (**-sL -n -oN** _filename_), randomize it with a Perl script, then provide the whole list to Nmap with **-iL**. **--spoof-mac** _MAC address, prefix, or vendor name_ (Spoof MAC address) Asks Nmap to use the given MAC address for all of the raw ethernet frames it sends. This option implies **--send-eth** to ensure that Nmap actually sends ethernet-level packets. The MAC given can take several formats. If it is simply the number 0, Nmap chooses a completely random MAC address for the session. If the given string is an even number of hex digits (with the pairs optionally separated by a colon), Nmap will use those as the MAC. If fewer than 12 hex digits are provided, Nmap fills in the remainder of the six bytes with random values. If the argument isn't a zero or hex string, Nmap looks through nmap-mac-prefixes to find a vendor name containing the given string (it is case insensitive). If a match is found, Nmap uses the vendor's OUI (three-byte prefix) and fills out the remaining three bytes randomly. Valid **--spoof-mac** argument examples are Apple, 0, 01:02:03:04:05:06, deadbeefcafe, 0020F2, and Cisco. This option only affects raw packet scans such as SYN scan or OS detection, not connection-oriented features such as version detection or the Nmap Scripting Engine. **--proxies** _Comma-separated list of proxy URLs_ (Relay TCP connections through a chain of proxies) Asks Nmap to establish TCP connections with a final target through supplied chain of one or more HTTP or SOCKS4 proxies. Proxies can help hide the true source of a scan or evade certain firewall restrictions, but they can hamper scan performance by increasing latency. Users may need to adjust Nmap timeouts and other scan parameters accordingly. In particular, a lower **--max-parallelism** may help because some proxies refuse to handle as many concurrent connections as Nmap opens by default. This option takes a list of proxies as argument, expressed as URLs in the format proto://host:port. Use commas to separate node URLs in a chain. No authentication is supported yet. Valid protocols are HTTP and SOCKS4. Warning: this feature is still under development and has limitations. It is implemented within the nsock library and thus has no effect on the ping, port scanning and OS discovery phases of a scan. Only NSE and version scan benefit from this option so far—other features may disclose your true address. SSL connections are not yet supported, nor is proxy-side DNS resolution (hostnames are always resolved by Nmap). **--badsum**(Send packets with bogus TCP/UDP checksums) Asks Nmap to use an invalid TCP, UDP or SCTP checksum for packets sent to target hosts. Since virtually all host IP stacks properly drop these packets, any responses received are likely coming from a firewall or IDS that didn't bother to verify the checksum. For more details on this technique, see **https://nmap.org/p60-12.html ** **--adler32**(Use deprecated Adler32 instead of CRC32C for SCTP checksums) Asks Nmap to use the deprecated Adler32 algorithm for calculating the SCTP checksum. If **--adler32** is not given, CRC-32C (Castagnoli) is used. **RFC 2960******[13] originally defined Adler32 as checksum algorithm for SCTP;**RFC 4960******[6] later redefined the SCTP checksums to use CRC-32C. Current SCTP implementations should be using CRC-32C, but in order to elicit responses from old, legacy SCTP implementations, it may be preferable to use Adler32. ## OUTPUT Any security tool is only as useful as the output it generates. Complex tests and algorithms are of little value if they aren't presented in an organized and comprehensible fashion. Given the number of ways Nmap is used by people and other software, no single format can please everyone. So Nmap offers several formats, including the interactive mode for humans to read directly and XML for easy parsing by software. In addition to offering different output formats, Nmap provides options for controlling the verbosity of output as well as debugging messages. Output types may be sent to standard output or to named files, which Nmap can append to or clobber. Output files may also be used to resume aborted scans. Nmap makes output available in five different formats. The default is called interactive output, and it is sent to standard output (stdout). There is also normal output, which is similar to interactive except that it displays less runtime information and warnings since it is expected to be analyzed after the scan completes rather than interactively. XML output is one of the most important output types, as it can be converted to HTML, easily parsed by programs such as Nmap graphical user interfaces, or imported into databases. The two remaining output types are the simple grepable output which includes most information for a target host on a single line, and sCRiPt KiDDi3 0utPUt for users who consider themselves |<-r4d. While interactive output is the default and has no associated command-line options, the other four format options use the same syntax. They take one argument, which is the filename that results should be stored in. Multiple formats may be specified, but each format may only be specified once. For example, you may wish to save normal output for your own review while saving XML of the same scan for programmatic analysis. You might do this with the options **-oX myscan.xml -oN myscan.nmap**. While this chapter uses the simple names like myscan.xml for brevity, more descriptive names are generally recommended. The names chosen are a matter of personal preference, though I use long ones that incorporate the scan date and a word or two describing the scan, placed in a directory named after the company I'm scanning. While these options save results to files, Nmap still prints interactive output to stdout as usual. For example, the command **nmap -oX myscan.xml target** prints XML to myscan.xml and fills standard output with the same interactive results it would have printed if **-oX** wasn't specified at all. You can change this by passing a hyphen character as the argument to one of the format types. This causes Nmap to deactivate interactive output, and instead print results in the format you specified to the standard output stream. So the command **nmap -oX - target** will send only XML output to stdout. Serious errors may still be printed to the normal error stream, stderr. Unlike some Nmap arguments, the space between the logfile option flag (such as **-oX**) and the filename or hyphen is mandatory. If you omit the flags and give arguments such as **-oG-** or **-oXscan.xml** , a backwards compatibility feature of Nmap will cause the creation of _normal format_ output files named G- and Xscan.xml respectively. All of these arguments support **strftime** -like conversions in the filename. %H, %M, %S, %m, %d, %y, and %Y are all exactly the same as in **strftime**. %T is the same as %H%M%S, %R is the same as %H%M, and %D is the same as %m%d%y. A % followed by any other character just yields that character (%% gives you a percent symbol). So **-oX** **'scan-%T-%D.xml'** will use an XML file with a name in the form of scan-144840-121307.xml. Nmap also offers options to control scan verbosity and to append to output files rather than clobbering them. All of these options are described below. **Nmap Output Formats** **-oN** _filespec_ (normal output) Requests that normal output be directed to the given filename. As discussed above, this differs slightly from interactive output. **-oX** _filespec_ (XML output) Requests that XML output be directed to the given filename. Nmap includes a document type definition (DTD) which allows XML parsers to validate Nmap XML output. While it is primarily intended for programmatic use, it can also help humans interpret Nmap XML output. The DTD defines the legal elements of the format, and often enumerates the attributes and values they can take on. The latest version is always available from **https://svn.nmap.org/nmap/docs/nmap.dtd ******. XML offers a stable format that is easily parsed by software. Free XML parsers are available for all major computer languages, including C/C++, Perl, Python, and Java. People have even written bindings for most of these languages to handle Nmap output and execution specifically. Examples are**Nmap::Scanner******[14] and**Nmap::Parser******[15] in Perl CPAN. In almost all cases that a non-trivial application interfaces with Nmap, XML is the preferred format. The XML output references an XSL stylesheet which can be used to format the results as HTML. The easiest way to use this is simply to load the XML output in a web browser such as Firefox or IE. By default, this will only work on the machine you ran Nmap on (or a similarly configured one) due to the hard-coded nmap.xsl filesystem path. Use the**--webxml** or **--stylesheet** options to create portable XML files that render as HTML on any web-connected machine. **-oS** _filespec_ (ScRipT KIdd|3 oUTpuT) Script kiddie output is like interactive output, except that it is post-processed to better suit the l33t HaXXorZ who previously looked down on Nmap due to its consistent capitalization and spelling. Humor impaired people should note that this option is making fun of the script kiddies before flaming me for supposedly “helping them”. **-oG** _filespec_ (grepable output) This output format is covered last because it is deprecated. The XML output format is far more powerful, and is nearly as convenient for experienced users. XML is a standard for which dozens of excellent parsers are available, while grepable output is my own simple hack. XML is extensible to support new Nmap features as they are released, while I often must omit those features from grepable output for lack of a place to put them. Nevertheless, grepable output is still quite popular. It is a simple format that lists each host on one line and can be trivially searched and parsed with standard Unix tools such as grep, awk, cut, sed, diff, and Perl. Even I usually use it for one-off tests done at the command line. Finding all the hosts with the SSH port open or that are running Solaris takes only a simple grep to identify the hosts, piped to an awk or cut command to print the desired fields. Grepable output consists of comments (lines starting with a pound (#)) and target lines. A target line includes a combination of six labeled fields, separated by tabs and followed with a colon. The fields are Host, Ports, Protocols, Ignored State, OS, Seq Index, IP ID, and Status. The most important of these fields is generally Ports, which gives details on each interesting port. It is a comma separated list of port entries. Each port entry represents one interesting port, and takes the form of seven slash (/) separated subfields. Those subfields are: Port number, State, Protocol, Owner, Service, SunRPC info, and Version info. As with XML output, this man page does not allow for documenting the entire format. A more detailed look at the Nmap grepable output format is available from **https://nmap.org/book/output-formats-grepable-output.html ******.**-oA** _basename_ (Output to all formats) As a convenience, you may specify **-oA** _basename_ to store scan results in normal, XML, and grepable formats at once. They are stored in _basename_.nmap, _basename_.xml, and _basename_.gnmap, respectively. As with most programs, you can prefix the filenames with a directory path, such as ~/nmaplogs/foocorp/ on Unix or c:\hacking\sco on Windows. **Verbosity and debugging options** **-v**(Increase verbosity level), **-v** _level_ (Set verbosity level) Increases the verbosity level, causing Nmap to print more information about the scan in progress. Open ports are shown as they are found and completion time estimates are provided when Nmap thinks a scan will take more than a few minutes. Use it twice or more for even greater verbosity: **-vv** , or give a verbosity level directly, for example **-v3**. Most changes only affect interactive output, and some also affect normal and script kiddie output. The other output types are meant to be processed by machines, so Nmap can give substantial detail by default in those formats without fatiguing a human user. However, there are a few changes in other modes where output size can be reduced substantially by omitting some detail. For example, a comment line in the grepable output that provides a list of all ports scanned is only printed in verbose mode because it can be quite long. **-d**(Increase debugging level), **-d** _level_ (Set debugging level) When even verbose mode doesn't provide sufficient data for you, debugging is available to flood you with much more! As with the verbosity option (**-v**), debugging is enabled with a command-line flag (**-d**) and the debug level can be increased by specifying it multiple times, as in **-dd** , or by setting a level directly. For example, **-d9** sets level nine. That is the highest effective level and will produce thousands of lines unless you run a very simple scan with very few ports and targets. Debugging output is useful when a bug is suspected in Nmap, or if you are simply confused as to what Nmap is doing and why. As this feature is mostly intended for developers, debug lines aren't always self-explanatory. You may get something like: Timeout vals: srtt: -1 rttvar: -1 to: 1000000 delta 14987 ==> srtt: 14987 rttvar: 14987 to: 100000. If you don't understand a line, your only recourses are to ignore it, look it up in the source code, or request help from the development list (nmap-dev). Some lines are self explanatory, but the messages become more obscure as the debug level is increased. **--reason**(Host and port state reasons) Shows the reason each port is set to a specific state and the reason each host is up or down. This option displays the type of the packet that determined a port or hosts state. For example, A RST packet from a closed port or an echo reply from an alive host. The information Nmap can provide is determined by the type of scan or ping. The SYN scan and SYN ping (**-sS** and **-PS**) are very detailed, but the TCP connect scan (**-sT**) is limited by the implementation of the **connect** system call. This feature is automatically enabled by the debug option (**-d**) and the results are stored in XML log files even if this option is not specified. **--stats-every** _time_ (Print periodic timing stats) Periodically prints a timing status message after each interval of _time_. The time is a specification of the kind described in the section called “TIMING AND PERFORMANCE”; so for example, use **--stats-every 10s** to get a status update every 10 seconds. Updates are printed to interactive output (the screen) and XML output. **--packet-trace**(Trace packets and data sent and received) Causes Nmap to print a summary of every packet sent or received. This is often used for debugging, but is also a valuable way for new users to understand exactly what Nmap is doing under the covers. To avoid printing thousands of lines, you may want to specify a limited number of ports to scan, such as **-p20-30**. If you only care about the goings on of the version detection subsystem, use **--version-trace** instead. If you only care about script tracing, specify **--script-trace**. With **--packet-trace** , you get all of the above. **--open**(Show only open (or possibly open) ports) Sometimes you only care about ports you can actually connect to (open ones), and don't want results cluttered with closed, filtered, and closed|filtered ports. Output customization is normally done after the scan using tools such as grep, awk, and Perl, but this feature was added due to overwhelming requests. Specify **--open** to only see hosts with at least one open, open|filtered, or unfiltered port, and only see ports in those states. These three states are treated just as they normally are, which means that open|filtered and unfiltered may be condensed into counts if there are an overwhelming number of them. Beginning with Nmap 7.40, the **--open** option implies **--defeat-rst-ratelimit** , because that option only affects closed and filtered ports, which are hidden by **--open**. **--iflist**(List interfaces and routes) Prints the interface list and system routes as detected by Nmap and quits. This is useful for debugging routing problems or device mischaracterization (such as Nmap treating a PPP connection as ethernet). **Miscellaneous output options** **--append-output**(Append to rather than clobber output files) When you specify a filename to an output format flag such as **-oX** or **-oN** , that file is overwritten by default. If you prefer to keep the existing content of the file and append the new results, specify the **--append-output** option. All output filenames specified in that Nmap execution will then be appended to rather than clobbered. This doesn't work well for XML (**-oX**) scan data as the resultant file generally won't parse properly until you fix it up by hand. **--resume** _filename_ (Resume aborted scan) Some extensive Nmap runs take a very long time—on the order of days. Such scans don't always run to completion. Restrictions may prevent Nmap from being run during working hours, the network could go down, the machine Nmap is running on might suffer a planned or unplanned reboot, or Nmap itself could crash. The administrator running Nmap could cancel it for any other reason as well, by pressing ctrl-C. Restarting the whole scan from the beginning may be undesirable. Fortunately, if scan output files were kept, the user can ask Nmap to resume scanning with the target it was working on when execution ceased. Simply specify the **--resume** option and pass the output file as its argument. No other arguments are permitted, as Nmap parses the output file to use the same ones specified previously. Simply call Nmap as **nmap --resume** _logfilename_. Nmap will append new results to the data files specified in the previous execution. Scans can be resumed from any of the 3 major output formats: Normal, Grepable, or XML **--noninteractive**(Disable runtime interactions) At times, such as when running Nmap in a shell background, it might be undesirable for Nmap to monitor and respond to user keyboard input when running. (See the section called “RUNTIME INTERACTION” about how to control Nmap during a scan.) Use option **--noninteractive** to prevent Nmap taking control of the terminal. **--stylesheet** _path or URL_ (Set XSL stylesheet to transform XML output) Nmap ships with an XSL stylesheet named nmap.xsl for viewing or translating XML output to HTML. The XML output includes an xml-stylesheet directive which points to nmap.xml where it was initially installed by Nmap. Run the XML file through an XSLT processor such as **xsltproc******[16] to produce an HTML file. Directly opening the XML file in a browser no longer works well because modern browsers limit the locations a stylesheet may be loaded from. If you wish to use a different stylesheet, specify it as the argument to**--stylesheet**. You must pass the full pathname or URL. One common invocation is **--stylesheet** **https://nmap.org/svn/docs/nmap.xsl **. This tells an XSLT processor to load the latest version of the stylesheet from Nmap.Org. The **--webxml** option does the same thing with less typing and memorization. Loading the XSL from Nmap.Org makes it easier to view results on a machine that doesn't have Nmap (and thus nmap.xsl) installed. So the URL is often more useful, but the local filesystem location of nmap.xsl is used by default for privacy reasons. **--webxml**(Load stylesheet from Nmap.Org) This is a convenience option, nothing more than an alias for **--stylesheethttps://nmap.org/svn/docs/nmap.xsl**. **--no-stylesheet**(Omit XSL stylesheet declaration from XML) Specify this option to prevent Nmap from associating any XSL stylesheet with its XML output. The xml-stylesheet directive is omitted. ## MISCELLANEOUS OPTIONS This section describes some important (and not-so-important) options that don't really fit anywhere else. **-6**(Enable IPv6 scanning) Nmap has IPv6 support for its most popular features. Ping scanning, port scanning, version detection, and the Nmap Scripting Engine all support IPv6. The command syntax is the same as usual except that you also add the **-6** option. Of course, you must use IPv6 syntax if you specify an address rather than a hostname. An address might look like 3ffe:7501:4819:2000:210:f3ff:fe03:14d0, so hostnames are recommended. The output looks the same as usual, with the IPv6 address on the “interesting ports” line being the only IPv6 giveaway. While IPv6 hasn't exactly taken the world by storm, it gets significant use in some (usually Asian) countries and most modern operating systems support it. To use Nmap with IPv6, both the source and target of your scan must be configured for IPv6. If your ISP (like most of them) does not allocate IPv6 addresses to you, free tunnel brokers are widely available and work fine with Nmap. I use the free IPv6 tunnel broker service at **http://www.tunnelbroker.net ******. Other tunnel brokers are**listed at Wikipedia******[17]. 6to4 tunnels are another popular, free approach. On Windows, raw-socket IPv6 scans are supported only on ethernet devices (not tunnels), and only on Windows Vista and later. Use the**--unprivileged** option in other situations. **-A**(Aggressive scan options) This option enables additional advanced and aggressive options. Presently this enables OS detection (**-O**), version scanning (**-sV**), script scanning (**-sC**) and traceroute (**--traceroute**). More features may be added in the future. The point is to enable a comprehensive set of scan options without people having to remember a large set of flags. However, because script scanning with the default set is considered intrusive, you should not use **-A** against target networks without permission. This option only enables features, and not timing options (such as **-T4**) or verbosity options (**-v**) that you might want as well. Options which require privileges (e.g. root access) such as OS detection and traceroute will only be enabled if those privileges are available. **--datadir** _directoryname_ (Specify custom Nmap data file location) Nmap obtains some special data at runtime in files named nmap-service-probes, nmap-services, nmap-protocols, nmap-rpc, nmap-mac-prefixes, and nmap-os-db. If the location of any of these files has been specified (using the **--servicedb** or **--versiondb** options), that location is used for that file. After that, Nmap searches these files in the directory specified with the **--datadir** option (if any). Any files not found there, are searched for in the directory specified by the **NMAPDIR** environment variable. Next comes ~/.nmap for real and effective UIDs; or on Windows, _HOME_ \AppData\Roaming\nmap (where _HOME_ is the user's home directory, like C:\Users\user). This is followed by the location of the nmap executable and the same location with ../share/nmap appended. Then a compiled-in location such as /usr/local/share/nmap or /usr/share/nmap. **--servicedb** _services file_ (Specify custom services file) Asks Nmap to use the specified services file rather than the nmap-services data file that comes with Nmap. Using this option also causes a fast scan (**-F**) to be used. See the description for **--datadir** for more information on Nmap's data files. **--versiondb** _service probes file_ (Specify custom service probes file) Asks Nmap to use the specified service probes file rather than the nmap-service-probes data file that comes with Nmap. See the description for **--datadir** for more information on Nmap's data files. **--send-eth**(Use raw ethernet sending) Asks Nmap to send packets at the raw ethernet (data link) layer rather than the higher IP (network) layer. By default, Nmap chooses the one which is generally best for the platform it is running on. Raw sockets (IP layer) are generally most efficient for Unix machines, while ethernet frames are required for Windows operation since Microsoft disabled raw socket support. Nmap still uses raw IP packets on Unix despite this option when there is no other choice (such as non-ethernet connections). **--send-ip**(Send at raw IP level) Asks Nmap to send packets via raw IP sockets rather than sending lower level ethernet frames. It is the complement to the **--send-eth** option discussed previously. **--privileged**(Assume that the user is fully privileged) Tells Nmap to simply assume that it is privileged enough to perform raw socket sends, packet sniffing, and similar operations that usually require root privileges on Unix systems. By default Nmap quits if such operations are requested but **geteuid** is not zero. **--privileged** is useful with Linux kernel capabilities and similar systems that may be configured to allow unprivileged users to perform raw-packet scans. Be sure to provide this option flag before any flags for options that require privileges (SYN scan, OS detection, etc.). The **NMAP_PRIVILEGED** environment variable may be set as an equivalent alternative to **--privileged**. **--unprivileged**(Assume that the user lacks raw socket privileges) This option is the opposite of **--privileged**. It tells Nmap to treat the user as lacking network raw socket and sniffing privileges. This is useful for testing, debugging, or when the raw network functionality of your operating system is somehow broken. The **NMAP_UNPRIVILEGED** environment variable may be set as an equivalent alternative to **--unprivileged**. **--release-memory**(Release memory before quitting) This option is only useful for memory-leak debugging. It causes Nmap to release allocated memory just before it quits so that actual memory leaks are easier to spot. Normally Nmap skips this as the OS does this anyway upon process termination. **-V** ; **--version**(Print version number) Prints the Nmap version number and exits. **-h** ; **--help**(Print help summary page) Prints a short help screen with the most common command flags. Running Nmap without any arguments does the same thing. ## RUNTIME INTERACTION During the execution of Nmap, all key presses are captured. This allows you to interact with the program without aborting and restarting it. Certain special keys will change options, while any other keys will print out a status message telling you about the scan. The convention is that _lowercase letters increase_ the amount of printing, and _uppercase letters decrease_ the printing. You may also press ‘ _?_ ’ for help. **v** / **V** Increase / decrease the verbosity level **d** / **D** Increase / decrease the debugging Level **p** / **P** Turn on / off packet tracing **?** Print a runtime interaction help screen Anything else Print out a status message like this: Stats: 0:00:07 elapsed; 20 hosts completed (1 up), 1 undergoing Service Scan Service scan Timing: About 33.33% done; ETC: 20:57 (0:00:12 remaining) ## EXAMPLES Here are some Nmap usage examples, from the simple and routine to a little more complex and esoteric. Some actual IP addresses and domain names are used to make things more concrete. In their place you should substitute addresses/names from _your own network_. While I don't think port scanning other networks is or should be illegal, some network administrators don't appreciate unsolicited scanning of their networks and may complain. Getting permission first is the best approach. For testing purposes, you have permission to scan the host scanme.nmap.org. This permission only includes scanning via Nmap and not testing exploits or denial of service attacks. To conserve bandwidth, please do not initiate more than a dozen scans against that host per day. If this free scanning target service is abused, it will be taken down and Nmap will report Failed to resolve given hostname/IP: scanme.nmap.org. These permissions also apply to the hosts scanme2.nmap.org, scanme3.nmap.org, and so on, though those hosts do not currently exist. **nmap -v scanme.nmap.org** This option scans all reserved TCP ports on the machine scanme.nmap.org . The **-v** option enables verbose mode. **nmap -sS -O scanme.nmap.org/24** Launches a stealth SYN scan against each machine that is up out of the 256 IPs on the /24 sized network where Scanme resides. It also tries to determine what operating system is running on each host that is up and running. This requires root privileges because of the SYN scan and OS detection. **nmap -sV -p 22,53,110,143,4564 198.116.0-255.1-127** Launches host enumeration and a TCP scan at the first half of each of the 255 possible eight-bit subnets in the 198.116.0.0/16 address space. This tests whether the systems run SSH, DNS, POP3, or IMAP on their standard ports, or anything on port 4564. For any of these ports found open, version detection is used to determine what application is running. **nmap -v -iR 100000 -Pn -p 80** Asks Nmap to choose 100,000 hosts at random and scan them for web servers (port 80). Host enumeration is disabled with **-Pn** since first sending a couple probes to determine whether a host is up is wasteful when you are only probing one port on each target host anyway. **nmap -Pn -p80 -oX logs/pb-port80scan.xml -oG** **logs/pb-port80scan.gnmap 216.163.128.20/20** This scans 4096 IPs for any web servers (without pinging them) and saves the output in grepable and XML formats. ## NMAP BOOK While this reference guide details all material Nmap options, it can't fully demonstrate how to apply those features to quickly solve real-world tasks. For that, we released Nmap Network Scanning: The Official Nmap Project Guide to Network Discovery and Security Scanning. Topics include subverting firewalls and intrusion detection systems, optimizing Nmap performance, and automating common networking tasks with the Nmap Scripting Engine. Hints and instructions are provided for common Nmap tasks such as taking network inventory, penetration testing, detecting rogue wireless access points, and quashing network worm outbreaks. Examples and diagrams show actual communication on the wire. More than half of the book is available free online. See **https://nmap.org/book******for more information. ## BUGS Like its author, Nmap isn't perfect. But you can help make it better by sending bug reports or even writing patches. If Nmap doesn't behave the way you expect, first upgrade to the latest version available from **https://nmap.org ******. If the problem persists, do some research to determine whether it has already been discovered and addressed. Try searching for the problem or error message on Google since that aggregates so many forums. If nothing comes of this, create an Issue on our tracker (‐**http://issues.nmap.org ******) and/or mail a bug report to <[email protected]>. If you subscribe to the nmap-dev list before posting, your message will bypass moderation and get through more quickly. Subscribe at **https://nmap.org/mailman/listinfo/dev ******. Please include everything you have learned about the problem, as well as what version of Nmap you are using and what operating system version it is running on. Other suggestions for improving Nmap may be sent to the Nmap dev mailing list as well. If you are able to write a patch improving Nmap or fixing a bug, that is even better! Instructions for submitting patches or git pull requests are available from**https://github.com/nmap/nmap/blob/master/CONTRIBUTING.md ** Particularly sensitive issues such as a security reports may be sent directly to Nmap's author Fyodor directly at <[email protected]>. All other reports and comments should use the dev list or issue tracker instead because more people read, follow, and respond to those. ## LEGAL NOTICES **Nmap Copyright and Licensing** The Nmap Security Scanner is (C) 1996–2022 Nmap Software LLC ("The Nmap Project"). Nmap is also a registered trademark of the Nmap Project. It is published under the **Nmap Public Source License******[18]. This generally allows end users to download and use Nmap for free. It doesn't allow Nmap to be used and redistributed within commercial software or hardware products (including appliances, virtual machines, and traditional applications). We fund the project by selling a special Nmap OEM Edition for this purpose, as described at**https://nmap.org/oem ******. Hundreds of large and small software vendors have already purchased OEM licenses to embed Nmap technology such as host discovery, port scanning, OS detection, version detection, and the Nmap Scripting Engine within their products. The Nmap Project has permission to redistribute Npcap, a packet capturing driver and library for the Microsoft Windows platform. Npcap is a separate work with it's own license rather than this Nmap license. Since the Npcap license does not permit redistribution without special permission, our Nmap Windows binary packages which contain Npcap may not be redistributed without special permission. Even though the NPSL is based on GPLv2, it contains different provisions and is not directly compatible. It is incompatible with some other open source licenses as well. In some cases we can relicense portions of Nmap or grant special permissions to use it in other open source software. Please contact [email protected] with any such requests. Similarly, we don't incorporate incompatible open source software into Nmap without special permission from the copyright holders. If you have received a written license agreement or contract for Nmap (such as an**Nmap OEM license******[19]) stating terms other than these, you may choose to use and redistribute Nmap under those terms instead.**Creative Commons License for this Nmap Guide** This Nmap Reference Guide is (C) 2005–2022 Nmap Software LLC. It is hereby placed under version 3.0 of the **Creative Commons** **Attribution License******[20]. This allows you redistribute and modify the work as you desire, as long as you credit the original source. Alternatively, you may choose to treat this document as falling under the same license as Nmap itself (discussed previously).**Source Code Availability and Community Contributions** Source is provided to this software because we believe users have a right to know exactly what a program is going to do before they run it. This also allows you to audit the software for security holes. Source code also allows you to port Nmap to new platforms, fix bugs, and add new features. You are highly encouraged to submit your changes as Github Pull Requests (PR) or send them to <[email protected]> for possible incorporation into the main distribution. By submitting such changes, it is assumed that you are offering the Nmap Project the unlimited, non-exclusive right to reuse, modify, and relicense the code. This is important because the inability to relicense code has caused devastating problems for other Free Software projects (such as KDE and NASM). We also sell commercial licenses to **Nmap OEM******[21]. If you wish to specify special license conditions of your contributions, just say so when you send them.**No Warranty** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It should also be noted that Nmap has occasionally been known to crash poorly written applications, TCP/IP stacks, and even operating systems. While this is extremely rare, it is important to keep in mind. _Nmap should never be run against mission_ _critical systems_ unless you are prepared to suffer downtime. We acknowledge here that Nmap may crash your systems or networks and we disclaim all liability for any damage or problems Nmap could cause. **Inappropriate Usage** Because of the slight risk of crashes and because a few black hats like to use Nmap for reconnaissance prior to attacking systems, there are administrators who become upset and may complain when their system is scanned. Thus, it is often advisable to request permission before doing even a light scan of a network. Nmap should never be installed with special privileges (e.g. suid root). That would open up a major security vulnerability as other users on the system (or attackers) could use it for privilege escalation. Nmap is not designed, manufactured, or intended for use in hazardous environments requiring fail- safe performance where the failure of the software could lead directly to death, personal injury, or significant physical or environmental damage. **Third-Party Software and Funding Notices** This product includes software developed by the **Apache Software** **Foundation******[22]. A modified version of the**Libpcap portable packet** **capture library******[23] is distributed along with Nmap. The Windows version of Nmap utilizes the Libpcap-derived**Ncap library******[24] instead. Regular expression support is provided by the**PCRE** **library******[25], which is open-source software, written by Philip Hazel. Certain raw networking functions use the**Libdnet******[26] networking library, which was written by Dug Song. A modified version is distributed with Nmap. Nmap can optionally link with the**OpenSSL cryptography toolkit******[27] for SSL version detection support. The Nmap Scripting Engine uses an embedded version of the**Lua programming language******[10]. The**Liblinear linear classification** **library******[28] is used for our**IPv6 OS detection machine learning** **techniques******[29]. All of the third-party software described in this paragraph is freely redistributable under BSD-style software licenses. Binary packages for Windows and Mac OS X include support libraries necessary to run Zenmap and Ndiff with Python and PyGTK. (Unix platforms commonly make these libraries easy to install, so they are not part of the packages.) A listing of these support libraries and their licenses is included in the LICENSES files. This software was supported in part through the**Google Summer of** **Code******[30] and the**DARPA CINDER program******[31] (DARPA-BAA-10-84).**United States Export Control** Nmap only uses encryption when compiled with the optional OpenSSL support and linked with OpenSSL. When compiled without OpenSSL support, the Nmap Project believes that Nmap is not subject to U.S. **Export Administration Regulations (EAR)******[32] export control. As such, there is no applicable ECCN (export control classification number) and exportation does not require any special license, permit, or other governmental authorization. When compiled with OpenSSL support or distributed as source code, the Nmap Project believes that Nmap falls under U.S. ECCN**5D002******[33] (“Information Security Software”). We distribute Nmap under the TSU exception for publicly available encryption software defined in**EAR 740.13(e)******[34]. ## NOTES 1. Nmap Network Scanning: The Official Nmap Project Guide to Network Discovery and Security Scanning https://nmap.org/book/ 2. RFC 1122 http://www.rfc-editor.org/rfc/rfc1122.txt 3. RFC 792 http://www.rfc-editor.org/rfc/rfc792.txt 4. RFC 950 http://www.rfc-editor.org/rfc/rfc950.txt 5. UDP http://www.rfc-editor.org/rfc/rfc768.txt 6. SCTP http://www.rfc-editor.org/rfc/rfc4960.txt 7. TCP RFC http://www.rfc-editor.org/rfc/rfc793.txt 8. RFC 959 http://www.rfc-editor.org/rfc/rfc959.txt 9. RFC 1323 http://www.rfc-editor.org/rfc/rfc1323.txt 10. Lua programming language https://lua.org 11. precedence http://www.lua.org/manual/5.4/manual.html#3.4.8 12. IP protocol http://www.rfc-editor.org/rfc/rfc791.txt 13. RFC 2960 http://www.rfc-editor.org/rfc/rfc2960.txt 14. Nmap::Scanner http://sourceforge.net/projects/nmap-scanner/ 15. Nmap::Parser http://nmapparser.wordpress.com/ 16. xsltproc http://xmlsoft.org/XSLT/ 17. listed at Wikipedia http://en.wikipedia.org/wiki/List_of_IPv6_tunnel_brokers 18. Nmap Public Source License https://nmap.org/npsl 19. Nmap OEM license https://nmap.org/oem/ 20. Creative Commons Attribution License http://creativecommons.org/licenses/by/3.0/ 21. Nmap OEM https://nmap.org/oem 22. Apache Software Foundation https://www.apache.org 23. Libpcap portable packet capture library https://www.tcpdump.org 24. Ncap library https://npcap.com 25. PCRE library https://pcre.org 26. Libdnet http://libdnet.sourceforge.net 27. OpenSSL cryptography toolkit https://openssl.org 28. Liblinear linear classification library https://www.csie.ntu.edu.tw/~cjlin/liblinear/ 29. IPv6 OS detection machine learning techniques https://nmap.org/book/osdetect-guess.html#osdetect-guess-ipv6 30. Google Summer of Code https://nmap.org/soc/ 31. DARPA CINDER program https://www.fbo.gov/index?s=opportunity&mode=form&id=585e02a51f77af5cb3c9e06b9cc82c48&tab=core&_cview=1 32. Export Administration Regulations (EAR) https://www.bis.doc.gov/index.php/regulations/export-administration-regulations-ear 33. 5D002 https://www.bis.doc.gov/index.php/documents/regulations-docs/federal-register-notices/federal-register-2014/951-ccl5-pt2/file 34. EAR 740.13(e) https://www.bis.doc.gov/index.php/documents/regulations-docs/2341-740-2/file * * *
# scp ## NAME **scp** — OpenSSH secure file copy ## SYNOPSIS **scp**[**-346ABCOpqRrsTv**] [**-c** _cipher_] [**-D** _sftp_server_path_] [**-F** _ssh_config_] [**-i** _identity_file_] [**-J** _destination_] [**-l** _limit_] [**-o** _ssh_option_] [**-P** _port_] [**-S** _program_] [**-X** _sftp_option_] _source ..._ _target_ ## DESCRIPTION **scp** copies files between hosts on a network. **scp** uses the SFTP protocol over a _ssh_(1) connection for data transfer, and uses the same authentication and provides the same security as a login session. **scp** will ask for passwords or passphrases if they are needed for authentication. The _source_ and _target_ may be specified as a local pathname, a remote host with optional path in the form [user@]host:[path], or a URI in the form scp://[user@]host[:port][/path]. Local file names can be made explicit using absolute or relative pathnames to avoid **scp** treating file names containing ‘:’ as host specifiers. When copying between two remote hosts, if the URI format is used, a _port_ cannot be specified on the _target_ if the **-R** option is used. The options are as follows: **-3** Copies between two remote hosts are transferred through the local host. Without this option the data is copied directly between the two remote hosts. Note that, when using the legacy SCP protocol (via the **-O** flag), this option selects batch mode for the second host as **scp** cannot ask for passwords or passphrases for both hosts. This mode is the default. **-4** Forces **scp** to use IPv4 addresses only. **-6** Forces **scp** to use IPv6 addresses only. **-A** Allows forwarding of _ssh-agent_(1) to the remote system. The default is not to forward an authentication agent. **-B** Selects batch mode (prevents asking for passwords or passphrases). **-C** Compression enable. Passes the **-C** flag to _ssh_(1) to enable compression. **-c** _cipher_ Selects the cipher to use for encrypting the data transfer. This option is directly passed to _ssh_(1). **-D** _sftp_server_path_ Connect directly to a local SFTP server program rather than a remote one via _ssh_(1). This option may be useful in debugging the client and server. **-F** _ssh_config_ Specifies an alternative per-user configuration file for **ssh**. This option is directly passed to _ssh_(1). **-i** _identity_file_ Selects the file from which the identity (private key) for public key authentication is read. This option is directly passed to _ssh_(1). **-J** _destination_ Connect to the target host by first making an **scp** connection to the jump host described by _destination_ and then establishing a TCP forwarding to the ultimate destination from there. Multiple jump hops may be specified separated by comma characters. This is a shortcut to specify a **ProxyJump** configuration directive. This option is directly passed to _ssh_(1). **-l** _limit_ Limits the used bandwidth, specified in Kbit/s. **-O** Use the legacy SCP protocol for file transfers instead of the SFTP protocol. Forcing the use of the SCP protocol may be necessary for servers that do not implement SFTP, for backwards-compatibility for particular filename wildcard patterns and for expanding paths with a ‘~’ prefix for older SFTP servers. **-o** _ssh_option_ Can be used to pass options to **ssh** in the format used in _ssh_config_(5). This is useful for specifying options for which there is no separate **scp** command-line flag. For full details of the options listed below, and their possible values, see _ssh_config_(5). AddressFamily BatchMode BindAddress BindInterface CanonicalDomains CanonicalizeFallbackLocal CanonicalizeHostname CanonicalizeMaxDots CanonicalizePermittedCNAMEs CASignatureAlgorithms CertificateFile CheckHostIP Ciphers Compression ConnectionAttempts ConnectTimeout ControlMaster ControlPath ControlPersist GlobalKnownHostsFile GSSAPIAuthentication GSSAPIDelegateCredentials HashKnownHosts Host HostbasedAcceptedAlgorithms HostbasedAuthentication HostKeyAlgorithms HostKeyAlias Hostname IdentitiesOnly IdentityAgent IdentityFile IPQoS KbdInteractiveAuthentication KbdInteractiveDevices KexAlgorithms KnownHostsCommand LogLevel MACs NoHostAuthenticationForLocalhost NumberOfPasswordPrompts PasswordAuthentication PKCS11Provider Port PreferredAuthentications ProxyCommand ProxyJump PubkeyAcceptedAlgorithms PubkeyAuthentication RekeyLimit RequiredRSASize SendEnv ServerAliveInterval ServerAliveCountMax SetEnv StrictHostKeyChecking TCPKeepAlive UpdateHostKeys User UserKnownHostsFile VerifyHostKeyDNS **-P** _port_ Specifies the port to connect to on the remote host. Note that this option is written with a capital ‘P’, because **-p** is already reserved for preserving the times and mode bits of the file. **-p** Preserves modification times, access times, and file mode bits from the source file. **-q** Quiet mode: disables the progress meter as well as warning and diagnostic messages from _ssh_(1). **-R** Copies between two remote hosts are performed by connecting to the origin host and executing **scp** there. This requires that **scp** running on the origin host can authenticate to the destination host without requiring a password. **-r** Recursively copy entire directories. Note that **scp** follows symbolic links encountered in the tree traversal. **-S** _program_ Name of _program_ to use for the encrypted connection. The program must understand _ssh_(1) options. **-T** Disable strict filename checking. By default when copying files from a remote host to a local directory **scp** checks that the received filenames match those requested on the command-line to prevent the remote end from sending unexpected or unwanted files. Because of differences in how various operating systems and shells interpret filename wildcards, these checks may cause wanted files to be rejected. This option disables these checks at the expense of fully trusting that the server will not send unexpected filenames. **-v** Verbose mode. Causes **scp** and _ssh_(1) to print debugging messages about their progress. This is helpful in debugging connection, authentication, and configuration problems. **-X** _sftp_option_ Specify an option that controls aspects of SFTP protocol behaviour. The valid options are: **nrequests** =_value_ Controls how many concurrent SFTP read or write requests may be in progress at any point in time during a download or upload. By default 64 requests may be active concurrently. **buffer** =_value_ Controls the maximum buffer size for a single SFTP read/write operation used during download or upload. By default a 32KB buffer is used. ## EXIT STATUS The **scp** utility exits 0 on success, and >0 if an error occurs. ## CAVEATS The legacy SCP protocol (selected by the **-O** flag) requires execution of the remote user's shell to perform _glob_(3) pattern matching. This requires careful quoting of any characters that have special meaning to the remote shell, such as quote characters. * * *
# uniq ## NAME uniq - report or omit repeated lines ## SYNOPSIS **uniq**[_OPTION_]... [_INPUT_ [_OUTPUT_]] ## DESCRIPTION Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output). With no options, matching lines are merged to the first occurrence. Mandatory arguments to long options are mandatory for short options too. **-c** , **--count** prefix lines by the number of occurrences **-d** , **--repeated** only print duplicate lines, one for each group **-D** print all duplicate lines **--all-repeated**[=_METHOD_] like **-D** , but allow separating groups with an empty line; METHOD={none(default),prepend,separate} **-f** , **--skip-fields** =_N_ avoid comparing the first N fields **--group**[=_METHOD_] show all items, separating groups with an empty line; METHOD={separate(default),prepend,append,both} **-i** , **--ignore-case** ignore differences in case when comparing **-s** , **--skip-chars** =_N_ avoid comparing the first N characters **-u** , **--unique** only print unique lines **-z** , **--zero-terminated** line delimiter is NUL, not newline **-w** , **--check-chars** =_N_ compare no more than N characters in lines **--help** display this help and exit **--version** output version information and exit A field is a run of blanks (usually spaces and/or TABs), then non-blank characters. Fields are skipped before chars. 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort **-u** ' without 'uniq'. * * *
# dh_auto_install ## NAME dh_auto_install - automatically runs make install or similar ## SYNOPSIS **dh_auto_install**[_build system options_] [_debhelper options_] [**--**_params_] ## DESCRIPTION **dh_auto_install** is a debhelper program that tries to automatically install built files. It does so by running the appropriate command for the build system it detects the package uses. For example, if there's a _Makefile_ and it contains a **install** target, then this is done by running **make**(or **MAKE** , if the environment variable is set). If there is a _setup.py_ or _Build.PL_ , it is used. Note that the Ant build system does not support installation, so **dh_auto_install** will not install files built using Ant. In compat 14 or later, **dh_auto_install** will use _debian/tmp_ as the default **--destdir** and should be moved from there to the appropriate package build directory using dh_install(1) or similar tools. Though if the **single-binary** addon for dh(1) is activated, then it will pass an explicit **--destdir=debian/_package_ / **to **dh_auto_install**. For earlier compat levels then unless **--destdir** option is specified, the files are installed into debian/_package_ / if there is only one binary package. In the multiple binary package case, the files are instead installed into _debian/tmp/_ , and should be moved from there to the appropriate package build directory using dh_install(1) or similar tools. **DESTDIR** is used to tell make where to install the files. If the Makefile was generated by MakeMaker from a _Makefile.PL_ , it will automatically set **PREFIX=/usr** too, since such Makefiles need that. This is intended to work for about 90% of packages. If it doesn't work, or tries to use the wrong install target, you're encouraged to skip using **dh_auto_install** at all, and just run make install manually. ## OPTIONS See "BUILD SYSTEM OPTIONS" in debhelper(7) for a list of common build system selection and control options. **--destdir=**_directory_ Install files into the specified _directory_. If this option is not specified, destination directory is determined automatically as described in the "**DESCRIPTION** " section. **--**_params_ Pass _params_ to the program that is run, after the parameters that **dh_auto_install** usually passes. * * *
# su ## NAME su - run a command with substitute user and group ID ## SYNOPSIS **su**[options] [**-**] [_user_ [_argument_...]] ## DESCRIPTION **su** allows commands to be run with a substitute user and group ID. When called with no _user_ specified, **su** defaults to running an interactive shell as _root_. When _user_ is specified, additional _argument_ s can be supplied, in which case they are passed to the shell. For backward compatibility, **su** defaults to not change the current directory and to only set the environment variables **HOME** and **SHELL** (plus **USER** and **LOGNAME** if the target _user_ is not root). It is recommended to always use the **--login** option (instead of its shortcut **-**) to avoid side effects caused by mixing environments. This version of **su** uses PAM for authentication, account and session management. Some configuration options found in other **su** implementations, such as support for a wheel group, have to be configured via PAM. **su** is mostly designed for unprivileged users, the recommended solution for privileged users (e.g., scripts executed by root) is to use non-set-user-ID command runuser(1) that does not require authentication and provides separate PAM configuration. If the PAM session is not required at all then the recommended solution is to use command setpriv(1). Note that **su** in all cases uses PAM (pam_getenvlist(3)) to do the final environment modification. Command-line options such as **--login** and **--preserve-environment** affect the environment before it is modified by PAM. Since version 2.38 **su** resets process resource limits RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_FSIZE, RLIMIT_AS and RLIMIT_NOFILE. ## OPTIONS **-c** , **--command** _command_ Pass _command_ to the shell with the **-c** option. **-f** , **--fast** Pass **-f** to the shell, which may or may not be useful, depending on the shell. **-g** , **--group** _group_ Specify the primary group. This option is available to the root user only. **-G** , **--supp-group** _group_ Specify a supplementary group. This option is available to the root user only. The first specified supplementary group is also used as a primary group if the option **--group** is not specified. **-** , **-l** , **--login** Start the shell as a login shell with an environment similar to a real login. Note that on systemd-based systems, a new session may be defined as a real entry point to the system. However, **su** does not create a real session (by PAM) from this point of view. You need to use tools like **systemd-run** or **machinectl** to initiate a complete, real session. **su** does: • clears all the environment variables except **TERM** , **COLORTERM** , **NO_COLOR** and variables specified by **--whitelist-environment** • initializes the environment variables **HOME** , **SHELL** , **USER** , **LOGNAME** , and **PATH** • changes to the target user’s home directory • sets argv[0] of the shell to '**-** ' in order to make the shell a login shell **-m** , **-p** , **--preserve-environment** Preserve the entire environment, i.e., do not set **HOME** , **SHELL** , **USER** or **LOGNAME**. This option is ignored if the option **--login** is specified. **-P** , **--pty** Create a pseudo-terminal for the session. The independent terminal provides better security as the user does not share a terminal with the original session. This can be used to avoid **TIOCSTI** ioctl terminal injection and other security attacks against terminal file descriptors. The entire session can also be moved to the background (e.g., **su --pty -**_user_ **-c** _application_ **&**). If the pseudo-terminal is enabled, then **su** works as a proxy between the sessions (sync stdin and stdout). This feature is mostly designed for interactive sessions. If the standard input is not a terminal, but for example a pipe (e.g., **echo "date" | su --pty**), then the **ECHO** flag for the pseudo-terminal is disabled to avoid messy output. **-s** , **--shell** _shell_ Run the specified _shell_ instead of the default. If the target user has a restricted shell (i.e., not listed in _/etc/shells_), the **--shell** option and the **SHELL** environment variables are ignored unless the calling user is root. The shell to run is selected according to the following rules, in order: • the shell specified with **--shell** • the shell specified in the environment variable **SHELL** , if the **--preserve-environment** option is used • the shell listed in the passwd entry of the target user • /bin/sh **--session-command=**_command_ Same as **-c** , but do not create a new session. (Discouraged.) **-T** , **--no-pty** Do not create a pseudo-terminal, opposite of **--pty** and **-P**. Note that running without a pseudo-terminal opens the security risk of privilege escalation through TIOCSTI/TIOCLINUX ioctl command injection. **-w** , **--whitelist-environment** _list_ Don’t reset the environment variables specified in the comma-separated _list_ when clearing the environment for **--login**. The whitelist is ignored for the environment variables **HOME** , **SHELL** , **USER** , **LOGNAME** , and **PATH**. **-h** , **--help** Display help text and exit. **-V** , **--version** Display version and exit. ## SIGNALS Upon receiving either **SIGINT** , **SIGQUIT** or **SIGTERM** , **su** terminates its child and afterwards terminates itself with the received signal. The child is terminated by **SIGTERM** , after unsuccessful attempt and 2 seconds of delay the child is killed by **SIGKILL**. ## CONFIG FILES **su** reads the _/etc/default/su_ and _/etc/login.defs_ configuration files. The following configuration items are relevant for **su** : **FAIL_DELAY**(number) Delay in seconds in case of an authentication failure. The number must be a non-negative integer. **ENV_PATH**(string) Defines the **PATH** environment variable for a regular user. The default value is _/usr/local/bin:/bin:/usr/bin_. **ENV_ROOTPATH**(string), **ENV_SUPATH**(string) Defines the **PATH** environment variable for root. **ENV_SUPATH** takes precedence. The default value is _/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin_. **ALWAYS_SET_PATH**(boolean) If set to _yes_ and **--login** and **--preserve-environment** were not specified **su** initializes **PATH**. The environment variable **PATH** may be different on systems where _/bin_ and _/sbin_ are merged into _/usr_ ; this variable is also affected by the **--login** command-line option and the PAM system setting (e.g., pam_env(8)). ## EXIT STATUS **su** normally returns the exit status of the command it executed. If the command was killed by a signal, **su** returns the number of the signal plus 128. Exit status generated by **su** itself: 1 Generic error before executing the requested command 126 The requested command could not be executed 127 The requested command was not found ## FILES _/etc/pam.d/su_ default PAM configuration file _/etc/pam.d/su-l_ PAM configuration file if **--login** is specified _/etc/default/su_ command specific logindef config file _/etc/login.defs_ global logindef config file ## NOTES For security reasons, **su** always logs failed log-in attempts to the _btmp_ file, but it does not write to the _lastlog_ file at all. This solution can be used to control **su** behavior by PAM configuration. If you want to use the pam_lastlog(8) module to print warning message about failed log-in attempts then pam_lastlog(8) has to be configured to update the _lastlog_ file as well. For example by: session required pam_lastlog.so nowtmp ## AVAILABILITY The **su** command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>. This page is part of the _util-linux_ (a random collection of Linux utilities) project. Information about the project can be found at ⟨https://www.kernel.org/pub/linux/utils/util-linux/⟩. If you have a bug report for this manual page, send it to [email protected]. This page was obtained from the project's upstream Git repository ⟨git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-05.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is _not_ part of the original manual page), send a mail to [email protected] util-linux 2.42-start-521-ec46 2025-08-09 _SU_(1) * * *
# genpmda ## NAME **genpmda** - Performance Co-Pilot PMDA Generator ## SYNOPSIS **genpmda**[**-dv**] [**-D** _domain_] [**-n** _pmns_] [**-o** _dir_] [**-s** _stdpmid_] [**-t** _topdir_] **-c** _config_ **-i** _IAM_ ## DESCRIPTION **genpmda** is a rapid application development tool for creating new Performance Metrics Domain Agents, see PMDA(3). It provides a very easy and efficient way to extend the Performance Co-pilot (PCP) with new performance metrics without needing to understand the low level details of how PMDAs are constructed. **genpmda** reads a config file containing an augmented Performance Metrics Name Space, see PMNS(5), and automatically generates virtually all of the source code to implement a fully functional PMDA, including the Makefile, name space, support scripts for configuring the new PMDA, and the metrics help text. Fairly simple PMDAs can be automatically generated from the config file without writing any additional code. More complicated PMDAs, e.g. containing multiple instance domains, require only the refresh methods for the instance domains to be written manually. An example of the config file format accepted by **genpmda** is given below. ## OPTIONS **Required options:** **-c** _config_ input _config_ file, see example below **-i** _IAM_ PMDA name _IAM_ , should appear in _stdpmid_ or the **-D** option must be used to specify a _domain_. **Other options:** **-d** generate an Install script for a daemon PMDA (default is DSO) **-D** _domain_ use _domain_ number in the generated **pmns** and **domain.h**(if **-s** is not given) **-n** _pmns_ use _pmns_ as root of the namespace (default matches **-i** flag) **-o** _dir_ use _dir_ for generated source code, default **./generated** **-s** _stdpmid_ path to _stdpmid_ (default **../../pmns/stdpmid**) **-t** _topdir_ use _topdir_ in generated GNUmakefile, default **../../..** **-v** print verbose messages about what **genpmda** is doing. Example: Generate an "example" PMDA using domain 99: **genpmda -D 99 -v -i EXAMPLE -c example.conf** Here is _example.conf_ config file (for the required **-c** option): example { metric } example.metric { ## metric string ## pmid EXAMPLE:CLUSTER:0 ## indom PM_INDOM_NULL ## type PM_TYPE_STRING ## units PMDA_PMUNITS(0,0,0,0,0,0) ## semantics PM_SEM_DISCRETE ## briefhelptext one line help text for example.metric.string ## helptext long help text for example.metric.string ## helptext This is the second line of the long help text ## helptext and this is the third line. ## fetch function example_string_fetch_callback ## code atom->cp = "hello world"; ## code return 1; ## endmetric } ## PCP ENVIRONMENT Environment variables with the prefix **PCP_** are used to parameterize the file and directory names used by PCP. On each installation, the file _/etc/pcp.conf_ contains the local values for these variables. The **$PCP_CONF** variable may be used to specify an alternative configuration file, as described in pcp.conf(5). * * *
# unlink ## PROLOG This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. ## NAME unlink — call the _unlink_() function ## SYNOPSIS unlink _file_ ## DESCRIPTION The _unlink_ utility shall perform the function call: unlink(_file_); A user may need appropriate privileges to invoke the _unlink_ utility. ## OPTIONS None. ## OPERANDS The following operands shall be supported: _file_ The pathname of an existing file. ## STDIN Not used. ## INPUT FILES Not used. ## ENVIRONMENT VARIABLES The following environment variables shall affect the execution of _unlink_ : _LANG_ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1‐2017, _Section 8.2_ , _Internationalization Variables_ for the precedence of internationalization variables used to determine the values of locale categories.) _LC_ALL_ If set to a non-empty string value, override the values of all the other internationalization variables. _LC_CTYPE_ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments). _LC_MESSAGES_ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. _NLSPATH_ Determine the location of message catalogs for the processing of _LC_MESSAGES_. ## ASYNCHRONOUS EVENTS Default. ## STDOUT None. ## STDERR The standard error shall be used only for diagnostic messages. ## OUTPUT FILES None. ## EXTENDED DESCRIPTION None. ## EXIT STATUS The following exit values shall be returned: 0 Successful completion. >0 An error occurred. ## CONSEQUENCES OF ERRORS Default. _The following sections are informative._ ## APPLICATION USAGE None. ## EXAMPLES None. ## RATIONALE None. ## FUTURE DIRECTIONS None. * * *
# ppdpo ## NAME ppdpo - ppd message catalog generator (deprecated) ## SYNOPSIS **ppdpo**[ **-D** _name_[**=**_value_] ] [ **-I** _include-directory_ ] [ **-o** _output-_ _file_ ] _source-file_ ## DESCRIPTION **ppdpo** extracts UI strings from PPDC source files and updates either a GNU gettext or macOS strings format message catalog source file for translation. **This program is deprecated and will** **be removed in a future release of CUPS.** ## OPTIONS **ppdpo** supports the following options: **-D** _name_[**=**_value_] Sets the named variable for use in the source file. It is equivalent to using the _#define_ directive in the source file. **-I** _include-directory_ Specifies an alternate include directory. Multiple _-I_ options can be supplied to add additional directories. **-o** _output-file_ Specifies the output file. The supported extensions are _.po_ or _.po.gz_ for GNU gettext format message catalogs and _.strings_ for macOS strings files. ## NOTES PPD files are deprecated and will no longer be supported in a future feature release of CUPS. Printers that do not support IPP can be supported using applications such as ippeveprinter(1). * * *
# gitweb ## NAME gitweb - Git web interface (web frontend to Git repositories) ## SYNOPSIS To get started with gitweb, run git-instaweb(1) from a Git repository. This will configure and start your web server, and run a web browser pointing to gitweb. ## DESCRIPTION Gitweb provides a web interface to Git repositories. Its features include: • Viewing multiple Git repositories with common root. • Browsing every revision of the repository. • Viewing the contents of files in the repository at any revision. • Viewing the revision log of branches, history of files and directories, seeing what was changed, when, and by whom. • Viewing the blame/annotation details of any file (if enabled). • Generating RSS and Atom feeds of commits, for any branch. The feeds are auto-discoverable in modern web browsers. • Viewing everything that was changed in a revision, and stepping through revisions one at a time, viewing the history of the repository. • Finding commits whose commit messages match a given search term. See **https://repo.or.cz/w/git.git/tree/HEAD:/gitweb/******for gitweb source code, browsed using gitweb itself. ## CONFIGURATION Various aspects of gitweb’s behavior can be controlled through the configuration file **gitweb_config.perl** or **/etc/gitweb.conf**. See the gitweb.conf(5) for details. **Repositories** Gitweb can show information from one or more Git repositories. These repositories have to be all on local filesystem, and have to share a common repository root, i.e. be all under a single parent repository (but see also the "Advanced web server setup" section, "Webserver configuration with multiple projects' root" subsection). our $projectroot = '/path/to/parent/directory'; The default value for **$projectroot** is **/pub/git**. You can change it during building gitweb via the **GITWEB_PROJECTROOT** build configuration variable. By default all Git repositories under **$projectroot** are visible and available to gitweb. The list of projects is generated by default by scanning the **$projectroot** directory for Git repositories (for object databases to be more exact; gitweb is not interested in a working area, and is best suited to showing "bare" repositories). The name of the repository in gitweb is the path to its **$GIT_DIR** (its object database) relative to **$projectroot**. Therefore the repository $repo can be found at "$projectroot/$repo". **Projects list file format** Instead of having gitweb find repositories by scanning the filesystem starting from $projectroot, you can provide a pre-generated list of visible projects by setting **$projects_list** to point to a plain text file with a list of projects (with some additional info). This file uses the following format: • One record (for project / repository) per line; does not support line continuation (newline escaping). • Leading and trailing whitespace are ignored. • Whitespace separated fields; any run of whitespace can be used as field separator (rules for Perl’s "**split**(" ", **$line**)"). • Fields use modified URI encoding, defined in RFC 3986, section 2.1 (Percent-Encoding), or rather "Query string encoding" (see **https://en.wikipedia.org/wiki/Query_string#URL_encoding ******), the difference being that SP (" ") can be encoded as "+" (and therefore "+" has to be also percent-encoded). Reserved characters are: "%" (used for encoding), "+" (can be used to encode SPACE), all whitespace characters as defined in Perl, including SP, TAB and LF, (used to separate fields in a record). • Currently recognized fields are: <repository path> path to repository GIT_DIR, relative to **$projectroot** <repository owner> displayed as repository owner, preferably full name, or email, or both You can generate the projects list index file using the project_index action (the _TXT_ link on projects list page) directly from gitweb; see also "Generating projects list using gitweb" section below. Example contents: foo.git Joe+R+Hacker+<[email protected]> foo/bar.git O+W+Ner+<[email protected]> By default this file controls only which projects are **visible** on projects list page (note that entries that do not point to correctly recognized Git repositories won’t be displayed by gitweb). Even if a project is not visible on projects list page, you can view it nevertheless by hand-crafting a gitweb URL. By setting **$strict_export** configuration variable (see gitweb.conf(5)) to true value you can allow viewing only of repositories also shown on the overview page (i.e. only projects explicitly listed in projects list file will be accessible). **Generating projects list using gitweb** We assume that GITWEB_CONFIG has its default Makefile value, namely _gitweb_config.perl_. Put the following in _gitweb_make_index.perl_ file: read_config_file("gitweb_config.perl"); $projects_list = $projectroot; Then create the following script to get list of project in the format suitable for GITWEB_LIST build configuration variable (or **$projects_list** variable in gitweb config): #!/bin/sh export GITWEB_CONFIG="gitweb_make_index.perl" export GATEWAY_INTERFACE="CGI/1.1" export HTTP_ACCEPT="*/*" export REQUEST_METHOD="GET" export QUERY_STRING="a=project_index" perl -- /var/www/cgi-bin/gitweb.cgi Run this script and save its output to a file. This file could then be used as projects list file, which means that you can set **$projects_list** to its filename. **Controlling access to Git repositories** By default all Git repositories under **$projectroot** are visible and available to gitweb. You can however configure how gitweb controls access to repositories. • As described in "Projects list file format" section, you can control which projects are **visible** by selectively including repositories in projects list file, and setting **$projects_list** gitweb configuration variable to point to it. With **$strict_export** set, projects list file can be used to control which repositories are **available** as well. • You can configure gitweb to only list and allow viewing of the explicitly exported repositories, via **$export_ok** variable in gitweb config file; see gitweb.conf(5) manpage. If it evaluates to true, gitweb shows repositories only if this file named by **$export_ok** exists in its object database (if directory has the magic file named **$export_ok**). For example git-daemon(1) by default (unless **--export-all** option is used) allows pulling only for those repositories that have _git-daemon-export-ok_ file. Adding our $export_ok = "git-daemon-export-ok"; makes gitweb show and allow access only to those repositories that can be fetched from via **git://** protocol. • Finally, it is possible to specify an arbitrary perl subroutine that will be called for each repository to determine if it can be exported. The subroutine receives an absolute path to the project (repository) as its only parameter (i.e. "$projectroot/$project"). For example, if you use mod_perl to run the script, and have dumb HTTP protocol authentication configured for your repositories, you can use the following hook to allow access only if the user is authorized to read the files: $export_auth_hook = sub { use Apache2::SubRequest (); use Apache2::Const -compile => qw(HTTP_OK); my $path = "$_[0]/HEAD"; my $r = Apache2::RequestUtil->request; my $sub = $r->lookup_file($path); return $sub->filename eq $path && $sub->status == Apache2::Const::HTTP_OK; }; **Per-repository gitweb configuration** You can configure individual repositories shown in gitweb by creating file in the **GIT_DIR** of Git repository, or by setting some repo configuration variable (in **GIT_DIR/config** , see git-config(1)). You can use the following files in repository: README.html A html file (HTML fragment) which is included on the gitweb project "summary" page inside _< div>_ block element. You can use it for longer description of a project, to provide links (for example to project’s homepage), etc. This is recognized only if XSS prevention is off (**$prevent_xss** is false, see gitweb.conf(5)); a way to include a README safely when XSS prevention is on may be worked out in the future. description (or **gitweb.description**) Short (shortened to **$projects_list_description_width** in the projects list page, which is 25 characters by default; see gitweb.conf(5)) single line description of a project (of a repository). Plain text file; HTML will be escaped. By default set to Unnamed repository; edit this file to name it for gitweb. from the template during repository creation, usually installed in **/usr/share/git-core/templates/**. You can use the **gitweb.description** repo configuration variable, but the file takes precedence. category (or **gitweb.category**) Single line category of a project, used to group projects if **$projects_list_group_categories** is enabled. By default (file and configuration variable absent), uncategorized projects are put in the **$project_list_default_category** category. You can use the **gitweb.category** repo configuration variable, but the file takes precedence. The configuration variables **$projects_list_group_categories** and **$project_list_default_category** are described in gitweb.conf(5) cloneurl (or multiple-valued **gitweb.url**) File with repository URL (used for clone and fetch), one per line. Displayed in the project summary page. You can use multiple-valued **gitweb.url** repository configuration variable for that, but the file takes precedence. This is per-repository enhancement / version of global prefix-based **@git_base_url_list** gitweb configuration variable (see gitweb.conf(5)). gitweb.owner You can use the **gitweb.owner** repository configuration variable to set repository’s owner. It is displayed in the project list and summary page. If it’s not set, filesystem directory’s owner is used (via GECOS field, i.e. real name field from getpwuid(3)) if **$projects_list** is unset (gitweb scans **$projectroot** for repositories); if **$projects_list** points to file with list of repositories, then project owner defaults to value from this file for given repository. various **gitweb.*** config variables (in config) Read description of **%feature** hash for detailed list, and descriptions. See also "Configuring gitweb features" section in gitweb.conf(5) ## ACTIONS, AND URLS Gitweb can use path_info (component) based URLs, or it can pass all necessary information via query parameters. The typical gitweb URLs are broken down in to five components: .../gitweb.cgi/<repo>/<action>/<revision>:/<path>?<arguments> repo The repository the action will be performed on. All actions except for those that list all available projects, in whatever form, require this parameter. action The action that will be run. Defaults to _projects_list_ if repo is not set, and to _summary_ otherwise. revision Revision shown. Defaults to HEAD. path The path within the <repository> that the action is performed on, for those actions that require it. arguments Any arguments that control the behaviour of the action. Some actions require or allow to specify two revisions, and sometimes even two pathnames. In most general form such path_info (component) based gitweb URL looks like this: .../gitweb.cgi/<repo>/<action>/<revision-from>:/<path-from>..<revision-to>:/<path-to>?<arguments> Each action is implemented as a subroutine, and must be present in %actions hash. Some actions are disabled by default, and must be turned on via feature mechanism. For example to enable _blame_ view add the following to gitweb configuration file: $feature{'blame'}{'default'} = [1]; **Actions:** The standard actions are: project_list Lists the available Git repositories. This is the default command if no repository is specified in the URL. summary Displays summary about given repository. This is the default command if no action is specified in URL, and only repository is specified. heads, remotes Lists all local or all remote-tracking branches in given repository. The latter is not available by default, unless configured. tags List all tags (lightweight and annotated) in given repository. blob, tree Shows the files and directories in a given repository path, at given revision. This is default command if no action is specified in the URL, and path is given. blob_plain Returns the raw data for the file in given repository, at given path and revision. Links to this action are marked _raw_. blobdiff Shows the difference between two revisions of the same file. blame, blame_incremental Shows the blame (also called annotation) information for a file. On a per line basis it shows the revision in which that line was last changed and the user that committed the change. The incremental version (which if configured is used automatically when JavaScript is enabled) uses Ajax to incrementally add blame info to the contents of given file. This action is disabled by default for performance reasons. commit, commitdiff Shows information about a specific commit in a repository. The _commit_ view shows information about commit in more detail, the _commitdiff_ action shows changeset for given commit. patch Returns the commit in plain text mail format, suitable for applying with git-am(1). tag Display specific annotated tag (tag object). log, shortlog Shows log information (commit message or just commit subject) for a given branch (starting from given revision). The _shortlog_ view is more compact; it shows one commit per line. history Shows history of the file or directory in a given repository path, starting from given revision (defaults to HEAD, i.e. default branch). This view is similar to _shortlog_ view. rss, atom Generates an RSS (or Atom) feed of changes to repository. ## WEBSERVER CONFIGURATION This section explains how to configure some common webservers to run gitweb. In all cases, **/path/to/gitweb** in the examples is the directory you ran installed gitweb in, and contains **gitweb_config.perl**. If you’ve configured a web server that isn’t listed here for gitweb, please send in the instructions so they can be included in a future release. **Apache as CGI** Apache must be configured to support CGI scripts in the directory in which gitweb is installed. Let’s assume that it is **/var/www/cgi-bin** directory. ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> Options Indexes FollowSymlinks ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> With that configuration the full path to browse repositories would be: http://server/cgi-bin/gitweb.cgi **Apache with mod_perl, via ModPerl::Registry** You can use mod_perl with gitweb. You must install Apache::Registry (for mod_perl 1.x) or ModPerl::Registry (for mod_perl 2.x) to enable this support. Assuming that gitweb is installed to **/var/www/perl** , the following Apache configuration (for mod_perl 2.x) is suitable. Alias /perl "/var/www/perl" <Directory "/var/www/perl"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options Indexes FollowSymlinks +ExecCGI AllowOverride None Order allow,deny Allow from all </Directory> With that configuration the full path to browse repositories would be: http://server/perl/gitweb.cgi **Apache with FastCGI** Gitweb works with Apache and FastCGI. First you need to rename, copy or symlink gitweb.cgi to gitweb.fcgi. Let’s assume that gitweb is installed in **/usr/share/gitweb** directory. The following Apache configuration is suitable (UNTESTED!) FastCgiServer /usr/share/gitweb/gitweb.cgi ScriptAlias /gitweb /usr/share/gitweb/gitweb.cgi Alias /gitweb/static /usr/share/gitweb/static <Directory /usr/share/gitweb/static> SetHandler default-handler </Directory> With that configuration the full path to browse repositories would be: http://server/gitweb ## ADVANCED WEB SERVER SETUP All of those examples use request rewriting, and need **mod_rewrite** (or equivalent; examples below are written for Apache). **Single URL for gitweb and for fetching** If you want to have one URL for both gitweb and your **http:// ** repositories, you can configure Apache like this: <VirtualHost *:80> ServerName git.example.org DocumentRoot /pub/git SetEnv GITWEB_CONFIG /etc/gitweb.conf # turning on mod rewrite RewriteEngine on # make the front page an internal rewrite to the gitweb script RewriteRule ^/$ /cgi-bin/gitweb.cgi # make access for "dumb clients" work RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] </VirtualHost> The above configuration expects your public repositories to live under **/pub/git** and will serve them as **http://git.domain.org/dir-under-pub-git **, both as clonable Git URL and as browsable gitweb interface. If you then start your git-daemon(1) with **--base-path=/pub/git --export-all** then you can even use the **git://** URL with exactly the same path. Setting the environment variable **GITWEB_CONFIG** will tell gitweb to use the named file (i.e. in this example **/etc/gitweb.conf**) as a configuration for gitweb. You don’t really need it in above example; it is required only if your configuration file is in different place than built-in (during compiling gitweb) _gitweb_config.perl_ or **/etc/gitweb.conf**. See gitweb.conf(5) for details, especially information about precedence rules. If you use the rewrite rules from the example you **might** also need something like the following in your gitweb configuration file (**/etc/gitweb.conf** following example): @stylesheets = ("/some/absolute/path/gitweb.css"); $my_uri = "/"; $home_link = "/"; $per_request_config = 1; Nowadays though gitweb should create HTML base tag when needed (to set base URI for relative links), so it should work automatically. **Webserver configuration with multiple projects' root** If you want to use gitweb with several project roots you can edit your Apache virtual host and gitweb configuration files in the following way. The virtual host configuration (in Apache configuration file) should look like this: <VirtualHost *:80> ServerName git.example.org DocumentRoot /pub/git SetEnv GITWEB_CONFIG /etc/gitweb.conf # turning on mod rewrite RewriteEngine on # make the front page an internal rewrite to the gitweb script RewriteRule ^/$ /cgi-bin/gitweb.cgi [QSA,L,PT] # look for a public_git directory in unix users' home # http://git.example.org/~<user>/ RewriteRule ^/\~([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] # http://git.example.org/+<user>/ #RewriteRule ^/\+([^\/]+)(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] # http://git.example.org/user/<user>/ #RewriteRule ^/user/([^\/]+)/(gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ [QSA,E=GITWEB_PROJECTROOT:/home/$1/public_git/,L,PT] # defined list of project roots RewriteRule ^/scm(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ [QSA,E=GITWEB_PROJECTROOT:/pub/scm/,L,PT] RewriteRule ^/var(/|/gitweb.cgi)?$ /cgi-bin/gitweb.cgi \ [QSA,E=GITWEB_PROJECTROOT:/var/git/,L,PT] # make access for "dumb clients" work RewriteRule ^/(.*\.git/(?!/?(HEAD|info|objects|refs)).*)?$ \ /cgi-bin/gitweb.cgi%{REQUEST_URI} [L,PT] </VirtualHost> Here actual project root is passed to gitweb via **GITWEB_PROJECT_ROOT** environment variable from a web server, so you need to put the following line in gitweb configuration file (**/etc/gitweb.conf** in above example): $projectroot = $ENV{'GITWEB_PROJECTROOT'} || "/pub/git"; **Note** that this requires to be set for each request, so either **$per_request_config** must be false, or the above must be put in code referenced by **$per_request_config** ; These configurations enable two things. First, each unix user (_< user>_) of the server will be able to browse through gitweb Git repositories found in **~/public_git/** with the following url: http://git.example.org/~<user>/ If you do not want this feature on your server just remove the second rewrite rule. If you already use ‘mod_userdir` in your virtual host or you don’t want to use the '~’ as first character, just comment or remove the second rewrite rule, and uncomment one of the following according to what you want. Second, repositories found in **/pub/scm/** and **/var/git/** will be accessible through **http://git.example.org/scm/** and **http://git.example.org/var/ **. You can add as many project roots as you want by adding rewrite rules like the third and the fourth. **PATH_INFO usage** If you enable PATH_INFO usage in gitweb by putting $feature{'pathinfo'}{'default'} = [1]; in your gitweb configuration file, it is possible to set up your server so that it consumes and produces URLs in the form http://git.example.com/project.git/shortlog/sometag i.e. without _gitweb.cgi_ part, by using a configuration such as the following. This configuration assumes that **/var/www/gitweb** is the DocumentRoot of your webserver, contains the gitweb.cgi script and complementary static files (stylesheet, favicon, JavaScript): <VirtualHost *:80> ServerAlias git.example.com DocumentRoot /var/www/gitweb <Directory /var/www/gitweb> Options ExecCGI AddHandler cgi-script cgi DirectoryIndex gitweb.cgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.* /gitweb.cgi/$0 [L,PT] </Directory> </VirtualHost> The rewrite rule guarantees that existing static files will be properly served, whereas any other URL will be passed to gitweb as PATH_INFO parameter. **Notice** that in this case you don’t need special settings for **@stylesheets** , **$my_uri** and **$home_link** , but you lose "dumb client" access to your project .git dirs (described in "Single URL for gitweb and for fetching" section). A possible workaround for the latter is the following: in your project root dir (e.g. **/pub/git**) have the projects named **without** a .git extension (e.g. **/pub/git/project** instead of **/pub/git/project.git**) and configure Apache as follows: <VirtualHost *:80> ServerAlias git.example.com DocumentRoot /var/www/gitweb AliasMatch ^(/.*?)(\.git)(/.*)?$ /pub/git$1$3 <Directory /var/www/gitweb> Options ExecCGI AddHandler cgi-script cgi DirectoryIndex gitweb.cgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.* /gitweb.cgi/$0 [L,PT] </Directory> </VirtualHost> The additional AliasMatch makes it so that http://git.example.com/project.git will give raw access to the project’s Git dir (so that the project can be cloned), while http://git.example.com/project will provide human-friendly gitweb access. This solution is not 100% bulletproof, in the sense that if some project has a named ref (branch, tag) starting with **git/** , then paths such as http://git.example.com/project/command/abranch..git/abranch will fail with a 404 error. ## BUGS Please report any bugs or feature requests to **[email protected]******[1], putting "gitweb" in the subject of email. ## GIT Part of the git(1) suite ## NOTES 1. [email protected] mailto:[email protected] * * *
# expr ## NAME expr - evaluate expressions ## SYNOPSIS **expr** _EXPRESSION_ **expr** _OPTION_ ## DESCRIPTION **--help** display this help and exit **--version** output version information and exit Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. EXPRESSION may be: ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 ARG1 < ARG2 ARG1 is less than ARG2 ARG1 <= ARG2 ARG1 is less than or equal to ARG2 ARG1 = ARG2 ARG1 is equal to ARG2 ARG1 != ARG2 ARG1 is unequal to ARG2 ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 ARG1 > ARG2 ARG1 is greater than ARG2 ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 ARG1 * ARG2 arithmetic product of ARG1 and ARG2 ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 STRING : REGEXP anchored pattern match of REGEXP in STRING match STRING REGEXP same as STRING : REGEXP substr STRING POS LENGTH substring of STRING, POS counted from 1 index STRING CHARS index in STRING where any CHARS is found, or 0 length STRING length of STRING + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ( EXPRESSION ) value of EXPRESSION Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicographical. Pattern matches return the string matched between \( and \) or null; if \( and \) are not used, they return the number of characters matched or 0. Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred. * * *
# lpoptions ## NAME lpoptions - display or set per-user printer options and defaults ## SYNOPSIS **lpoptions**[ **-h** _server_[**:**_port_] ] [ **-E**] **-d** _destination_[**/**_instance_] [ **-l**] **lpoptions**[ **-h** _server_[**:**_port_] ] [ **-E**] [ **-p** _destination_[**/**_instance_] ] **-o** _option_[**=**_value_] ... **lpoptions**[ **-h** _server_[**:**_port_] ] [ **-E**] [ **-p** _destination_[**/**_instance_] ] **-r** _option_ **lpoptions**[ **-h** _server_[**:**_port_] ] [ **-E**] **-x** _destination_[**/**_instance_] ## DESCRIPTION **lpoptions** displays or sets printer options and defaults. If no printer is specified using the _-p_ option, the default printer is used as described in lp(1). If no _-l_ , _-o_ , or _-r_ options are specified, the current options are reported on the standard output. Options set with the **lpoptions** command are used by the lp(1) and lpr(1) commands when submitting jobs. When run by the root user, **lpoptions** gets and sets default options and instances for all users in the _/etc/cups/lpoptions_ file. Otherwise, the per-user defaults are managed in the _~/.cups/lpoptions_ file. ## OPTIONS **lpoptions** supports the following options: **-E** Enables encryption when communicating with the CUPS server. **-d** _destination_[**/**_instance_] Sets the user default printer to _destination_. If _instance_ is supplied then that particular instance is used. This option overrides the system default printer for the current user. **-h** _server_[**:**_port_] Uses an alternate server. Note: This option must occur before all others. **-l** Lists the printer specific options and their current settings. **-o** _option_[**=**_value_] Specifies a new option for the named destination. **-p** _destination_[**/**_instance_] Sets the destination and instance, if specified, for any options that follow. If the named instance does not exist then it is created. Destinations can only be created using the lpadmin(8) program. **-r** _option_ Removes the specified option from the named destination. **-x** _destination_[**/**_instance_] Removes the options for the named destination and instance, if specified. If the named instance does not exist then this does nothing. Destinations can only be removed using the lpadmin(8) command. ## ENVIRONMENT The following environment variables override the default destination: **LPDEST** Specifies the default print queue (System V standard). **PRINTER** Specifies the default print queue (Berkeley standard). ## FILES _~/.cups/lpoptions_ - user defaults and instances created by non- root users. _/etc/cups/lpoptions_ - system-wide defaults and instances created by the root user. ## CONFORMING TO The **lpoptions** command is unique to CUPS. * * *
# mkfifo ## NAME mkfifo - make FIFOs (named pipes) ## SYNOPSIS **mkfifo**[_OPTION_]... _NAME_... ## DESCRIPTION Create named pipes (FIFOs) with the given NAMEs. Mandatory arguments to long options are mandatory for short options too. **-m** , **--mode** =_MODE_ set file permission bits to MODE, not a=rw - umask **-Z** set the SELinux security context to default type **--context**[=_CTX_] like **-Z** , or if CTX is specified then set the SELinux or SMACK security context to CTX **--help** display this help and exit **--version** output version information and exit * * *
# tabs ## PROLOG This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. ## NAME tabs — set terminal tabs ## SYNOPSIS tabs **[** -_n_ |-a|-a2|-c|-c2|-c3|-f|-p|-s|-u**] [** -T _type_**]** tabs **[** -T _type_**]**_n_**[[**_sep_**[** +**]**_n_**]**...**]** ## DESCRIPTION The _tabs_ utility shall display a series of characters that first clears the hardware terminal tab settings and then initializes the tab stops at the specified positions and optionally adjusts the margin. The phrase ``tab-stop position _N_ '' shall be taken to mean that, from the start of a line of output, tabbing to position _N_ shall cause the next character output to be in the (_N_ +1)th column position on that line. The maximum number of tab stops allowed is terminal-dependent. It need not be possible to implement _tabs_ on certain terminals. If the terminal type obtained from the _TERM_ environment variable or **-T** option represents such a terminal, an appropriate diagnostic message shall be written to standard error and _tabs_ shall exit with a status greater than zero. ## OPTIONS The _tabs_ utility shall conform to the Base Definitions volume of POSIX.1‐2017, _Section 12.2_ , _Utility Syntax Guidelines_ , except for various extensions: the options **-a2** , **-c2** , and **-c3** are multi- character. The following options shall be supported: **-**_n_ Specify repetitive tab stops separated by a uniform number of column positions, _n_ , where _n_ is a single-digit decimal number. The default usage of _tabs_ with no arguments shall be equivalent to _tabs_ -8. When **-0** is used, the tab stops shall be cleared and no new ones set. **-a** 1,10,16,36,72 Assembler, applicable to some mainframes. **-a2** 1,10,16,40,72 Assembler, applicable to some mainframes. **-c** 1,8,12,16,20,55 COBOL, normal format. **-c2** 1,6,10,14,49 COBOL, compact format (columns 1 to 6 omitted). **-c3** 1,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,67 COBOL compact format (columns 1 to 6 omitted), with more tabs than **-c2**. **-f** 1,7,11,15,19,23 FORTRAN **-p** 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61 PL/1 **-s** 1,10,55 SNOBOL **-u** 1,12,20,44 Assembler, applicable to some mainframes. **-T** _type_ Indicate the type of terminal. If this option is not supplied and the _TERM_ variable is unset or null, an unspecified default terminal type shall be used. The setting of _type_ shall take precedence over the value in _TERM_. ## OPERANDS The following operand shall be supported: _n_**[[**_sep_**[** +**]**_n_**]**...**]** A single command line argument that consists of one or more tab-stop values (_n_) separated by a separator character (_sep_) which is either a <comma> or a <blank> character. The application shall ensure that the tab- stop values are positive decimal integers in strictly ascending order. If any tab-stop value (except the first one) is preceded by a <plus-sign>, it is taken as an increment to be added to the previous value. For example, the tab lists 1,10,20,30 and **"1** 10**+10** +10" are considered to be identical. ## STDIN Not used. ## INPUT FILES None. ## ENVIRONMENT VARIABLES The following environment variables shall affect the execution of _tabs_ : _LANG_ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1‐2017, _Section 8.2_ , _Internationalization Variables_ for the precedence of internationalization variables used to determine the values of locale categories.) _LC_ALL_ If set to a non-empty string value, override the values of all the other internationalization variables. _LC_CTYPE_ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments). _LC_MESSAGES_ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. _NLSPATH_ Determine the location of message catalogs for the processing of _LC_MESSAGES_. _TERM_ Determine the terminal type. If this variable is unset or null, and if the **-T** option is not specified, an unspecified default terminal type shall be used. ## ASYNCHRONOUS EVENTS Default. ## STDOUT If standard output is a terminal, the appropriate sequence to clear and set the tab stops may be written to standard output in an unspecified format. If standard output is not a terminal, undefined results occur. ## STDERR The standard error shall be used only for diagnostic messages. ## OUTPUT FILES None. ## EXTENDED DESCRIPTION None. ## EXIT STATUS The following exit values shall be returned: 0 Successful completion. >0 An error occurred. ## CONSEQUENCES OF ERRORS Default. _The following sections are informative._ ## APPLICATION USAGE This utility makes use of the terminal's hardware tabs and the _stty tabs_ option. This utility is not recommended for application use. Some integrated display units might not have escape sequences to set tab stops, but may be set by internal system calls. On these terminals, _tabs_ works if standard output is directed to the terminal; if output is directed to another file, however, _tabs_ fails. ## EXAMPLES None. ## RATIONALE Consideration was given to having the _tput_ utility handle all of the functions described in _tabs_. However, the separate _tabs_ utility was retained because it seems more intuitive to use a command named _tabs_ than _tput_ with a new option. The _tput_ utility does not support setting or clearing tabs, and no known historical version of _tabs_ supports the capability of setting arbitrary tab stops. The System V _tabs_ interface is very complex; the version in this volume of POSIX.1‐2017 has a reduced feature list, but many of the features omitted were restored as part of the XSI option even though the supported languages and coding styles are primarily historical. There was considerable sentiment for specifying only a means of resetting the tabs back to a known state—presumably the ``standard'' of tabs every eight positions. The following features were omitted: * Setting tab stops via the first line in a file, using --_file_. Since even the SVID has no complete explanation of this feature, it is doubtful that it is in widespread use. In an early proposal, a **-t** _tablist_ option was added for consistency with _expand_ ; this was later removed when inconsistencies with the historical list of tabs were identified. Consideration was given to adding a **-p** option that would output the current tab settings so that they could be saved and then later restored. This was not accepted because querying the tab stops of the terminal is not a capability in historical _terminfo_ or _termcap_ facilities and might not be supported on a wide range of terminals. ## FUTURE DIRECTIONS None. * * *
# dh_installchangelogs ## NAME dh_installchangelogs - install changelogs into package build directories ## SYNOPSIS **dh_installchangelogs**[_debhelper options_] [**-k**] [**-X** _item_] [**--no-trim**] [_upstream_] ## DESCRIPTION **dh_installchangelogs** is a debhelper program that is responsible for installing changelogs into package build directories. An upstream _changelog_ file may be specified as an option. If none is specified, **dh_installchangelogs** may look for files with names that seem likely to be changelogs as described in the next paragraphs. In non-native packages, **dh_installchangelogs** will first look for changelog files installed by the upstream build system into _usr/share/doc/package_ (of the package build directory) and rename the most likely candidate (if any) to _usr/share/doc/package/changelog_. Note that **dh_installchangelogs** does _not_ look into any source directory (such as _debian/tmp_). Otherwise, **dh_installchangelogs**(at compatibility level 7 or any later) will look for changelog files in the source directory (e.g. the root or the _docs_ subdirectory). It will look for _changelog_ , _changes_ and _history_ optionally with common extensions (such as _.txt_ , _.md_ , _.rst_ , _.org_ , etc.) If a changelog file is specified and is an _html_ file (determined by file extension), it will be installed as _usr/share/doc/package/changelog.html_ instead. If the html changelog is converted to plain text, that variant can be specified as a second parameter. When no plain text variant is specified, a short _usr/share/doc/package/changelog_ is generated, pointing readers at the html changelog file. The **debchange** -style Debian changelogs are trimmed to include only entries more recent than the release date of _oldstable_. No trimming will be performed if the **--no-trim** option is passed or if the **DEB_BUILD_OPTIONS** environment variable contains **notrimdch**. ## FILES _debian/changelog_ _debian/NEWS_ debian/_package_.changelog debian/_package_.NEWS Automatically installed into usr/share/doc/_package_ / in the package build directory. Use the package specific name if _package_ needs a different _NEWS_ or _changelog_ file. The _changelog_ file is installed with a name of changelog for native packages, and _changelog.Debian_ for non-native packages. The _NEWS_ file is always installed with a name of _NEWS.Debian_. ## OPTIONS **-k** , **--keep** Keep the original name of the upstream changelog. This will be accomplished by installing the upstream changelog as _changelog_ , and making a symlink from that to the original name of the _changelog_ file. This can be useful if the upstream changelog has an unusual name, or if other documentation in the package refers to the _changelog_ file. **-X** _item_ , **--exclude=**_item_ Exclude upstream _changelog_ files that contain _item_ anywhere in their filename from being installed. Note that directory name of the changelog is also part of the match. **--no-trim** Install the full changelog, not its trimmed version that includes only recent entries. _upstream_ Install this file as the upstream changelog. * * *
# uuidparse ## NAME uuidparse - a utility to parse unique identifiers ## SYNOPSIS **uuidparse**[options] _uuid_ ## DESCRIPTION This command will parse unique identifier inputs from either command line arguments or standard input. The inputs are white-space separated. ## OUTPUT **Variants** ┌───────────┬──────────────────────────┐ │ │ │ │ NCS │ Network Computing System │ │ │ identifier. These were │ │ │ the original UUIDs. │ ├───────────┼──────────────────────────┤ │ │ │ │ DCE │ The Open Software │ │ │ Foundation’s (OSF) │ │ │ Distributed Computing │ │ │ Environment UUIDs. │ ├───────────┼──────────────────────────┤ │ │ │ │ Microsoft │ Microsoft Windows │ │ │ platform globally unique │ │ │ identifier (GUID). │ ├───────────┼──────────────────────────┤ │ │ │ │ other │ Unknown variant. Usually │ │ │ invalid input data. │ └───────────┴──────────────────────────┘ **Types** ┌────────────┬──────────────────────────┐ │ │ │ │ nil │ Special type for zero in │ │ │ type file. │ ├────────────┼──────────────────────────┤ │ │ │ │ time-based │ The DCE time based. │ ├────────────┼──────────────────────────┤ │ │ │ │ DCE │ The DCE time and MAC │ │ │ Address. │ ├────────────┼──────────────────────────┤ │ │ │ │ name-based │ RFC 4122 md5sum hash. │ ├────────────┼──────────────────────────┤ │ │ │ │ random │ RFC 4122 random. │ ├────────────┼──────────────────────────┤ │ │ │ │ sha1-based │ RFC 4122 sha-1 hash. │ ├────────────┼──────────────────────────┤ │ │ │ │ unknown │ Unknown type. Usually │ │ │ invalid input data. │ └────────────┴──────────────────────────┘ ## OPTIONS **-J** , **--json** Use JSON output format. **-n** , **--noheadings** Do not print a header line. **-o** , **--output** Specify which output columns to print. Use **--help** to get a list of all supported columns. **-r** , **--raw** Use the raw output format. **-h** , **--help** Display help text and exit. **-V** , **--version** Display version and exit. ## AVAILABILITY The **uuidparse** command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>. This page is part of the _util-linux_ (a random collection of Linux utilities) project. Information about the project can be found at ⟨https://www.kernel.org/pub/linux/utils/util-linux/⟩. If you have a bug report for this manual page, send it to [email protected]. This page was obtained from the project's upstream Git repository ⟨git://git.kernel.org/pub/scm/utils/util-linux/util-linux.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-05.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which is _not_ part of the original manual page), send a mail to [email protected] util-linux 2.42-start-521-ec46 2025-08-09 _UUIDPARSE_(1) * * *
# unexpand ## PROLOG This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. ## NAME unexpand — convert spaces to tabs ## SYNOPSIS unexpand **[** -a|-t _tablist_**] [**_file_...**]** ## DESCRIPTION The _unexpand_ utility shall copy files or standard input to standard output, converting <blank> characters at the beginning of each line into the maximum number of <tab> characters followed by the minimum number of <space> characters needed to fill the same column positions originally filled by the translated <blank> characters. By default, tabstops shall be set at every eighth column position. Each <backspace> shall be copied to the output, and shall cause the column position count for tab calculations to be decremented; the count shall never be decremented to a value less than one. ## OPTIONS The _unexpand_ utility shall conform to the Base Definitions volume of POSIX.1‐2017, _Section 12.2_ , _Utility Syntax Guidelines_. The following options shall be supported: **-a** In addition to translating <blank> characters at the beginning of each line, translate all sequences of two or more <blank> characters immediately preceding a tab stop to the maximum number of <tab> characters followed by the minimum number of <space> characters needed to fill the same column positions originally filled by the translated <blank> characters. **-t** _tablist_ Specify the tab stops. The application shall ensure that the _tablist_ option-argument is a single argument consisting of a single positive decimal integer or multiple positive decimal integers, separated by <blank> or <comma> characters, in ascending order. If a single number is given, tabs shall be set _tablist_ column positions apart instead of the default 8. If multiple numbers are given, the tabs shall be set at those specific column positions. The application shall ensure that each tab-stop position _N_ is an integer value greater than zero, and the list shall be in strictly ascending order. This is taken to mean that, from the start of a line of output, tabbing to position _N_ shall cause the next character output to be in the (_N_ +1)th column position on that line. When the **-t** option is not specified, the default shall be the equivalent of specifying **-t 8**(except for the interaction with **-a** , described below). No <space>-to-<tab> conversions shall occur for characters at positions beyond the last of those specified in a multiple tab-stop list. When **-t** is specified, the presence or absence of the **-a** option shall be ignored; conversion shall not be limited to the processing of leading <blank> characters. ## OPERANDS The following operand shall be supported: _file_ A pathname of a text file to be used as input. ## STDIN See the INPUT FILES section. ## INPUT FILES The input files shall be text files. ## ENVIRONMENT VARIABLES The following environment variables shall affect the execution of _unexpand_ : _LANG_ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1‐2017, _Section 8.2_ , _Internationalization Variables_ for the precedence of internationalization variables used to determine the values of locale categories.) _LC_ALL_ If set to a non-empty string value, override the values of all the other internationalization variables. _LC_CTYPE_ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files), the processing of <tab> and <space> characters, and for the determination of the width in column positions each character would occupy on an output device. _LC_MESSAGES_ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. _NLSPATH_ Determine the location of message catalogs for the processing of _LC_MESSAGES_. ## ASYNCHRONOUS EVENTS Default. ## STDOUT The standard output shall be equivalent to the input files with the specified <space>-to-<tab> conversions. ## STDERR The standard error shall be used only for diagnostic messages. ## OUTPUT FILES None. ## EXTENDED DESCRIPTION None. ## EXIT STATUS The following exit values shall be returned: 0 Successful completion. >0 An error occurred. ## CONSEQUENCES OF ERRORS Default. _The following sections are informative._ ## APPLICATION USAGE One non-intuitive aspect of _unexpand_ is its restriction to leading <space> characters when neither **-a** nor **-t** is specified. Users who always want to convert all <space> characters in a file can easily alias _unexpand_ to use the **-a** or **-t 8** option. ## EXAMPLES None. ## RATIONALE On several occasions, consideration was given to adding a **-t** option to the _unexpand_ utility to complement the **-t** in _expand_ (see expand(1p)). The historical intent of _unexpand_ was to translate multiple <blank> characters into tab stops, where tab stops were a multiple of eight column positions on most UNIX systems. An early proposal omitted **-t** because it seemed outside the scope of the User Portability Utilities option; it was not described in any of the base documents for IEEE Std 1003.2‐1992. However, hard-coding tab stops every eight columns was not suitable for the international community and broke historical precedents for some vendors in the FORTRAN community, so **-t** was restored in conjunction with the list of valid extension categories considered by the standard developers. Thus, _unexpand_ is now the logical converse of _expand_. ## FUTURE DIRECTIONS None. * * *
# mariadb ## NAME mariadb - the MariaDB command-line tool (mysql is now a symlink to mariadb) ## SYNOPSIS **mariadb [**_options_**]**_db_name_ ## DESCRIPTION **mariadb** is a simple SQL shell (with GNU readline capabilities). It supports interactive and non-interactive use. When used interactively, query results are presented in an ASCII-table format. When used non-interactively (for example, as a filter), the result is presented in tab-separated format. The output format can be changed using command options. If you have problems due to insufficient memory for large result sets, use the **--quick** option. This forces **mariadb** to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the mariadb_use_result() C API function in the client/server library rather than mysql_store_result(). Using **mariadb** is very easy. Invoke it from the prompt of your command interpreter as follows: shell> **mariadb** _db_name_ Or: shell> **mariadb --user=**_user_name_ **--password=**_your_password db_name_ Then type an SQL statement, end it with “;”, \g, or \G and press Enter. Typing Control-C causes **mariadb** to attempt to kill the current statement. If this cannot be done, or Control-C is typed again before the statement is killed, **mariadb** exits. You can execute SQL statements in a script file (batch file) like this: shell> **mariadb** _db_name_ **< **_script.sql_ **> **_output.tab_ ## MARIADB OPTIONS **mariadb** supports the following options, which can be specified on the command line or in the [mariadb], [client], [client-server] or [client-mariadb] option file groups. **mariadb** also supports the options for processing option files. • **--help** , **-?** , **-I** Display a help message and exit. • **--abort-source-on-error** Abort 'source filename' operations in case of errors. • **--auto-rehash** Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use **--disable-auto-rehash** , **--no-auto-rehash** , or **--skip-auto-rehash** to disable rehashing. That causes **mariadb** to start faster, but you must issue the rehash command if you want to use name completion. To complete a name, enter the first part and press Tab. If the name is unambiguous, **mariadb** completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database. • **--auto-vertical-output** Automatically switch to vertical output mode if the result is wider than the terminal width. • **--batch** , **-B** Print results using tab as the column separator, with each row on a new line. With this option, **mariadb** does not use the history file. Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the **--raw** option. • **--binary-mode** Binary mode allows certain character sequences to be processed as data that would otherwise be treated with a special meaning by the parser. Specifically, this switch turns off parsing of all client commands except \C and DELIMITER in non-interactive mode (i.e., when binary mode is combined with either 1) piped input, 2) the --batch mariadb option, or 3) the 'source' command). Also, in binary mode, occurrences of '\r\n' and ASCII '\0' are preserved within strings, whereas by default, '\r\n' is translated to '\n' and '\0' is disallowed in user input. • **--character-sets-dir=**_path_ The directory where character sets are installed. • **--column-names** Write column names in results. • **--column-type-info** , **-m** Display result set metadata. • **--comments** , **-c** Whether to preserve comments in statements sent to the server. The default is --skip-comments (discard comments), enable with --comments (preserve comments). • **--compress** , **-C** Compress all information sent between the client and the server if both support compression. • **--connect-timeout=**_seconds_ Set the number of seconds before connection timeout. (Default value is 0.) • **--database=**_db_name_ , **-D** _db_name_ The database to use. • **--debug[=**_debug_options_**]** , **-# [**_debug_options_**]** Write a debugging log. A typical _debug_options_ string is 'd:t:o,_file_name_ '. The default is 'd:t:o,/tmp/mysql.trace'. • **--debug-check** Print some debugging information when the program exits. • **--debug-info** , **-T** Prints debugging information and memory and CPU usage statistics when the program exits. • **--default-auth=**_name_ Default authentication client-side plugin to use. • **--default-character-set=**_charset_name_ Use _charset_name_ as the default character set for the client and connection. A common issue that can occur when the operating system uses utf8 or another multi-byte character set is that output from the **mariadb** client is formatted incorrectly, due to the fact that the MariaDB client uses the latin1 character set by default. You can usually fix such issues by using this option to force the client to use the system character set instead. • **--defaults-extra-file=**_filename_ Set _filename_ as the file to read default options from after the global defaults files has been read. Must be given as first option. • **--defaults-file=**_filename_ Set _filename_ as the file to read default options from, override global defaults files. Must be given as first option. • **--defaults-group-suffix=**_suffix_ In addition to the groups named on the command line, read groups that have the given suffix. • **--delimiter=**_str_ Set the statement delimiter. The default is the semicolon character (“;”). • **--disable-named-commands** Disable named commands. Use the \* form only, or use named commands only at the beginning of a line ending with a semicolon (“;”). **mariadb** starts with this option _enabled_ by default. However, even with this option, long-format commands still work from the first line. See the section called “MARIADB COMMANDS”. • **--enable-cleartext-plugin** Obsolete option. Exists only for MySQL compatibility. • **--execute=**_statement_ , **-e** _statement_ Execute the statement and quit. Disables **--force** and history file. The default output format is like that produced with **--batch**. • **--force** , **-f** Continue even if an SQL error occurs. Sets **--abort-source-on-** **error** to 0. • **--host=**_host_name_ , **-h** _host_name_ Connect to the MariaDB server on the given host. • **--html** , **-H** Produce HTML output. • **--ignore-spaces** , **-i** Ignore spaces after function names. Allows one to have spaces (including tab characters and new line characters) between function name and '('. The drawback is that this causes built in functions to become reserved words. • **--init-command=**_str_ SQL Command to execute when connecting to the MariaDB server. Will automatically be re-executed when reconnecting. • **--line-numbers** Write line numbers for errors. Disable this with **--skip-line-numbers**. • **--local-infile[={0|1}]** Enable or disable LOCAL capability for LOAD DATA INFILE. With no value, the option enables LOCAL. The option may be given as **--local-infile=0** or **--local-infile=1** to explicitly disable or enable LOCAL. Enabling LOCAL has no effect if the server does not also support it. • **--max-allowed-packet=**_num_ Set the maximum packet length to send to or receive from the server. (Default value is 16MB, largest 1GB.) • **--max-join-size=**_num_ Set the automatic limit for rows in a join when using **--safe-updates**. (Default value is 1,000,000.) • **--named-commands** , **-G** Enable named **mariadb** commands. Long-format commands are allowed, not just short-format commands. For example, quit and \q both are recognized. Use **--skip-named-commands** to disable named commands. See the section called “MARIADB COMMANDS”. Disabled by default. •• **--net-buffer-length=**_size_ Set the buffer size for TCP/IP and socket communication. (Default value is 16KB.) • **--no-auto-rehash** , **-A** This has the same effect as **--skip-auto-rehash**. See the description for **--auto-rehash**. • **--no-beep** , **-b** Do not beep when errors occur. • **--no-defaults** Do not read default options from any option file. This must be given as the first argument. • **--one-database** , **-o** Ignore statements except those those that occur while the default database is the one named on the command line. This filtering is limited, and based only on USE statements. This is useful for skipping updates to other databases in the binary log. • **--pager[=**_command_**]** Use the given command for paging query output. If the command is omitted, the default pager is the value of your PAGER environment variable. Valid pagers are **less** , **more** , **cat [ >** **filename]** , and so forth. This option works only on Unix and only in interactive mode. To disable paging, use **--skip-pager**. the section called “MARIADB COMMANDS”, discusses output paging further. • **--password[=**_password_**]** , **-p[**_password_**]** The password to use when connecting to the server. If you use the short option form (**-p**), you _cannot_ have a space between the option and the password. If you omit the _password_ value following the **--password** or **-p** option on the command line, **mariadb** prompts for one. Specifying a password on the command line should be considered insecure. You can use an option file to avoid giving the password on the command line. • **--pipe** , **-W** On Windows, connect to the server via a named pipe. This option applies only if the server supports named-pipe connections. • **--plugin-dir=**_dir_name_ Directory for client-side plugins. • **--port=**_port_num_ , **-P** _port_num_ The TCP/IP port number to use for the connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). Forces --protocol=tcp when specified on the command line without other connection properties. • **--print-defaults** Print the program argument list and exit. This must be given as the first argument. • **--progress-reports** Get progress reports for long running commands (such as ALTER TABLE). (Defaults to on; use **--skip-progress-reports** to disable.) • **--prompt=**_format_str_ Set the prompt to the specified format. The special sequences that the prompt can contain are described in the section called “MARIADB COMMANDS”. • **--protocol={TCP|SOCKET|PIPE|MEMORY}** The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. • **--quick** , **-q** Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option, **mariadb** does not use the history file. • **--raw** , **-r** For tabular output, the “boxing” around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the **--batch** or **--silent** option is given), special characters are escaped in the output so they can be identified easily. Newline, tab, NUL, and backslash are written as \n, \t, \0, and \\. The **--raw** option disables this character escaping. The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping: % **mariadb** mariadb> SELECT CHAR(92); +----------+ | CHAR(92) | +----------+ | \ | +----------+ % **mariadb -s** mariadb> SELECT CHAR(92); CHAR(92) \\ % **mariadb -s -r** mariadb> SELECT CHAR(92); CHAR(92) \ • **--reconnect** If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. Enabled by default, to disable use **--skip-reconnect** or **--disable-reconnect**. • **--safe-updates** , **--i-am-a-dummy** , **-U** Allow only those UPDATE and DELETE statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using **--safe-updates** on the command line. See the section called “MARIADB TIPS”, for more information about this option. • **--secure-auth** Do not send passwords to the server in old (pre-4.1.1) format. This prevents connections except for servers that use the newer password format. • **--select-limit=**_limit_ Set automatic limit for SELECT when using **--safe-updates**. (Default value is 1,000.) • **--server-arg=**_name_ Send _name_ as a parameter to the embedded server. • **--show-warnings** Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode. • **--sigint-ignore** Ignore SIGINT signals (typically the result of typing Control-C). • **--silent** , **-s** Silent mode. Produce less output. This option can be given multiple times to produce less and less output. This option results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the **--raw** option. • **--skip-auto-rehash** Disable automatic rehashing. Synonym for **--disable-auto-rehash**. • **--skip-column-names** , **-N** Do not write column names in results. • **--skip-line-numbers** , **-L** Do not write line numbers for errors. Useful when you want to compare result files that include error messages. • **--socket=**_path_ , **-S** _path_ For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use. Forces --protocol=socket when specified on the command line without other connection properties; on Windows, forces --protocol=pipe. • **--ssl** Enable SSL for connection (automatically enabled with other flags). Disable with **--skip-ssl**. • **--ssl-ca=**_name_ CA file in PEM format (check OpenSSL docs, implies **--ssl**). • **--ssl-capath=**_name_ CA directory (check OpenSSL docs, implies **--ssl**). • **--ssl-cert=**_name_ X509 cert in PEM format (check OpenSSL docs, implies **--ssl**). • **--ssl-cipher=**_name_ SSL cipher to use (check OpenSSL docs, implies **--ssl**). • **--ssl-key=**_name_ X509 key in PEM format (check OpenSSL docs, implies **--ssl**). • **--ssl-crl=**_name_ Certificate revocation list (check OpenSSL docs, implies **--ssl**). • **--ssl-crlpath=**_name_ Certificate revocation list path (check OpenSSL docs, implies **--ssl**). • **--ssl-verify-server-cert** Verify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default. • **--table** , **-t** Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode. • **--tee=**_file_name_ Append a copy of output to the given file. This option works only in interactive mode. the section called “MARIADB COMMANDS”, discusses tee files further. • **--unbuffered** , **-n** Flush the buffer after each query. • **--user=**_user_name_ , **-u** _user_name_ The MariaDB user name to use when connecting to the server. • **--verbose** , **-v** Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example, **-v -v -v** produces table output format even in batch mode.) • **--version** , **-V** Display version information and exit. • **--vertical** , **-E** Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with \G. • **--wait** , **-w** If the connection cannot be established, wait and retry instead of aborting. • **--xml** , **-X** Produce XML output. The output when **--xml** is used with **mariadb** matches that of **mariadb-dump --xml**. See mariadb-dump(1) for details. The XML output also uses an XML namespace, as shown here: shell> **mariadb --xml -uroot -e "SHOW VARIABLES LIKE 'version%'"** <?xml version="1.0"?> <resultset statement="SHOW VARIABLES LIKE 'version%'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <field name="Variable_name">version</field> <field name="Value">5.0.40-debug</field> </row> <row> <field name="Variable_name">version_comment</field> <field name="Value">Source distribution</field> </row> <row> <field name="Variable_name">version_compile_machine</field> <field name="Value">i686</field> </row> <row> <field name="Variable_name">version_compile_os</field> <field name="Value">suse-linux-gnu</field> </row> </resultset> You can also set the following variables by using **--**_var_name_**=**_value_. • connect_timeout The number of seconds before connection timeout. (Default value is 0.) • max_allowed_packet The maximum packet length to send to or receive from the server. (Default value is 16MB.) • max_join_size The automatic limit for rows in a join when using **--safe-updates**. (Default value is 1,000,000.) • net_buffer_length The buffer size for TCP/IP and socket communication. (Default value is 16KB.) • select_limit The automatic limit for SELECT statements when using **--safe-updates**. (Default value is 1,000.) On Unix, the **mariadb** client writes a record of executed statements to a history file. By default, this file is named .mariadb_history and is created in your home directory. For backwards compatibility .mariadb_history will be used if present and .mariadb_history is missing. To specify a different file, set the value of the MARIADB_HISTFILE environment variable. The environment variable MYSQL_HISTFILE will be used if MARIADB_HISTFILE isn't present. The .mariadb_history should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords. If you do not want to maintain a history file, first remove .mariadb_history if it exists, and then use either of the following techniques: • Set the MARIADB_HISTFILE variable to /dev/null. To cause this setting to take effect each time you log in, put the setting in one of your shell's startup files. • Create .mariadb_history as a symbolic link to /dev/null: shell> **ln -s /dev/null $HOME/.mariadb_history** You need do this only once. ## MARIADB COMMANDS **mariadb** sends each SQL statement that you issue to the server to be executed. There is also a set of commands that **mariadb** itself interprets. For a list of these commands, type help or \h at the mariadb> prompt: mariadb> **help** List of all MariaDB commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for 'help'. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. edit (\e) Edit command with $EDITOR. ego (\G) Send command to mariadb server, display result vertically. exit (\q) Exit mariadb. Same as quit. go (\g) Send command to mariadb server. help (\h) Display this help. nopager (\n) Disable pager, print to stdout. notee (\t) Don't write into outfile. pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. print (\p) Print current command. prompt (\R) Change your mariadb prompt. quit (\q) Quit mariadb. rehash (\#) Rebuild completion hash. source (\.) Execute an SQL script file. Takes a file name as an argument. status (\s) Get status information from the server. system (\!) Execute a system shell command. tee (\T) Set outfile [to_outfile]. Append everything into given outfile. use (\u) Use another database. Takes database name as argument. charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. warnings (\W) Show warnings after every statement. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' Each command has both a long and short form. The long form is not case sensitive; the short form is. The long form can be followed by an optional semicolon terminator, but the short form should not. The use of short-form commands within multi-line /* ... */ comments is not supported. • **help [**_arg_**]** , **\h [**_arg_**]** , **\? [**_arg_**]** , **? [**_arg_**]** Display a help message listing the available **mariadb** commands. If you provide an argument to the help command, **mariadb** uses it as a search string to access server-side help. For more information, see the section called “MARIADB SERVER-SIDE HELP”. • **charset** _charset_name_ , **\C** _charset_name_ Change the default character set and issue a SET NAMES statement. This enables the character set to remain synchronized on the client and server if **mariadb** is run with auto-reconnect enabled (which is not recommended), because the specified character set is used for reconnects. • **clear** , **\c** Clear the current input. Use this if you change your mind about executing the statement that you are entering. • **connect [**_db_name host_name_**]]** , **\r [**_db_name host_name_**]]** Reconnect to the server. The optional database name and host name arguments may be given to specify the default database or the host where the server is running. If omitted, the current values are used. • **delimiter** _str_ , **\d** _str_ Change the string that **mariadb** interprets as the separator between SQL statements. The default is the semicolon character (“;”). The delimiter can be specified as an unquoted or quoted argument. Quoting can be done with either single quote (') or double quote (") characters. To include a quote within a quoted string, either quote the string with the other quote character or escape the quote with a backslash (“\”) character. Backslash should be avoided outside of quoted strings because it is the escape character for MariaDB. For an unquoted argument, the delimiter is read up to the first space or end of line. For a quoted argument, the delimiter is read up to the matching quote on the line. When the delimiter recognized by **mariadb** is set to something other than the default of “;”, instances of that character are sent to the server without interpretation. However, the server itself still interprets “;” as a statement delimiter and processes statements accordingly. This behavior on the server side comes into play for multiple-statement execution, and for parsing the body of stored procedures and functions, triggers, and events. • **edit** , **\e** Edit the current input statement. **mariadb** checks the values of the EDITOR and VISUAL environment variables to determine which editor to use. The default editor is **vi** if neither variable is set. The **edit** command works only in Unix. • **ego** , **\G** Send the current statement to the server to be executed and display the result using vertical format. • **exit** , **\q** Exit **mariadb**. • **go** , **\g** Send the current statement to the server to be executed. • **nopager** , **\n** Disable output paging. See the description for **pager**. The **nopager** command works only in Unix. • **notee** , **\t** Disable output copying to the tee file. See the description for **tee**. • **nowarning** , **\w** Enable display of warnings after each statement. • **pager [**_command_**]** , **\P [**_command_**]** Enable output paging. By using the **--pager** option when you invoke **mariadb** , it is possible to browse or search query results in interactive mode with Unix programs such as **less** , **more** , or any other similar program. If you specify no value for the option, **mariadb** checks the value of the PAGER environment variable and sets the pager to that. Pager functionality works only in interactive mode. Output paging can be enabled interactively with the **pager** command and disabled with **nopager**. The command takes an optional argument; if given, the paging program is set to that. With no argument, the pager is set to the pager that was set on the command line, or stdout if no pager was specified. Output paging works only in Unix because it uses the popen() function, which does not exist on Windows. For Windows, the **tee** option can be used instead to save query output, although it is not as convenient as **pager** for browsing output in some situations. • **print** , **\p** Print the current input statement without executing it. • **prompt [**_str_**]** , **\R [**_str_**]** Reconfigure the **mariadb** prompt to the given string. The special character sequences that can be used in the prompt are described later in this section. If you specify the prompt command with no argument, **mariadb** resets the prompt to the default of mariadb>. • **quit** , **\q** Exit **mariadb**. • **rehash** , **\#** Rebuild the completion hash that enables database, table, and column name completion while you are entering statements. (See the description for the **--auto-rehash** option.) • **source** _file_name_ , **\.**_file_name_ Read the named file and executes the statements contained therein. On Windows, you can specify path name separators as / or \\. • **status** , **\s** Provide status information about the connection and the server you are using. If you are running in **--safe-updates** mode, status also prints the values for the **mariadb** variables that affect your queries. • **system** _command_ , **\!**_command_ Execute the given command using your default command interpreter. The **system** command works only in Unix. • **tee [**_file_name_**]** , **\T [**_file_name_**]** By using the **--tee** option when you invoke **mariadb** , you can log statements and their output. All the data displayed on the screen is appended into a given file. This can be very useful for debugging purposes also. **mariadb** flushes results to the file after each statement, just before it prints its next prompt. Tee functionality works only in interactive mode. You can enable this feature interactively with the **tee** command. Without a parameter, the previous file is used. The **tee** file can be disabled with the **notee** command. Executing **tee** again re-enables logging. • **use** _db_name_ , **\u** _db_name_ Use _db_name_ as the default database. • **warnings** , **\W** Enable display of warnings after each statement (if there are any). Here are a few tips about the **pager** command: • You can use it to write to a file and the results go only to the file: mariadb> **pager cat > /tmp/log.txt** You can also pass any options for the program that you want to use as your pager: mariadb> **pager less -n -i -S** • In the preceding example, note the **-S** option. You may find it very useful for browsing wide query results. Sometimes a very wide result set is difficult to read on the screen. The **-S** option to **less** can make the result set much more readable because you can scroll it horizontally using the left-arrow and right-arrow keys. You can also use **-S** interactively within **less** to switch the horizontal-browse mode on and off. For more information, read the **less** manual page: shell> **man less** • The **-F** and **-X** options may be used with **less** to cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary: mariadb> **pager less -n -i -S -F -X** • You can specify very complex pager commands for handling query output: mariadb> **pager cat | tee /dr1/tmp/res.txt \** **| tee /dr2/tmp/res2.txt | less -n -i -S** In this example, the command would send query results to two files in two different directories on two different file systems mounted on /dr1 and /dr2, yet still display the results onscreen via **less**. You can also combine the **tee** and **pager** functions. Have a **tee** file enabled and **pager** set to **less** , and you are able to browse the results using the **less** program and still have everything appended into a file the same time. The difference between the Unix **tee** used with the **pager** command and the **mariadb** built-in **tee** command is that the built-in **tee** works even if you do not have the Unix **tee** available. The built-in **tee** also logs everything that is printed on the screen, whereas the Unix **tee** used with **pager** does not log quite that much. Additionally, **tee** file logging can be turned on and off interactively from within **mariadb**. This is useful when you want to log some queries to a file, but not others. The **prompt** command reconfigures the default mariadb> prompt. The string for defining the prompt can contain the following special sequences. ┌────────┬────────────────────────────┐ │ **Option** │ **Description** │ ├────────┼────────────────────────────┤ │ \c │ A counter that │ │ │ increments for each │ │ │ statement you issue │ ├────────┼────────────────────────────┤ │ \D │ The full current date │ ├────────┼────────────────────────────┤ │ \d │ The default database │ ├────────┼────────────────────────────┤ │ \h │ The server host │ ├────────┼────────────────────────────┤ │ \l │ The current delimiter │ │ │ (new in 5.1.12) │ ├────────┼────────────────────────────┤ │ \m │ Minutes of the current │ │ │ time │ ├────────┼────────────────────────────┤ │ \n │ A newline character │ ├────────┼────────────────────────────┤ │ \O │ The current month in │ │ │ three-letter format │ │ │ (Jan, Feb, ...) │ ├────────┼────────────────────────────┤ │ \o │ The current month in │ │ │ numeric format │ ├────────┼────────────────────────────┤ │ \P │ am/pm │ ├────────┼────────────────────────────┤ │ \p │ The current TCP/IP port │ │ │ or socket file │ ├────────┼────────────────────────────┤ │ \R │ The current time, in │ │ │ 24-hour military time │ │ │ (0–23) │ ├────────┼────────────────────────────┤ │ \r │ The current time, │ │ │ standard 12-hour time │ │ │ (1–12) │ ├────────┼────────────────────────────┤ │ \S │ Semicolon │ ├────────┼────────────────────────────┤ │ \s │ Seconds of the current │ │ │ time │ ├────────┼────────────────────────────┤ │ \t │ A tab character │ ├────────┼────────────────────────────┤ │ \U │ │ │ │ Your full │ │ │ _user_name_ @_host_name_ │ │ │ account name │ ├────────┼────────────────────────────┤ │ \u │ Your user name │ ├────────┼────────────────────────────┤ │ \v │ The server version │ ├────────┼────────────────────────────┤ │ \w │ The current day of the │ │ │ week in three-letter │ │ │ format (Mon, Tue, ...) │ ├────────┼────────────────────────────┤ │ \Y │ The current year, four │ │ │ digits │ ├────────┼────────────────────────────┤ │ \y │ The current year, two │ │ │ digits │ ├────────┼────────────────────────────┤ │ \_ │ A space │ ├────────┼────────────────────────────┤ │ \ │ A space (a space follows │ │ │ the backslash) │ ├────────┼────────────────────────────┤ │ \' │ Single quote │ ├────────┼────────────────────────────┤ │ \" │ Double quote │ ├────────┼────────────────────────────┤ │ \\ │ A literal “\” backslash │ │ │ character │ ├────────┼────────────────────────────┤ │ \_x_ │ │ │ │ _x_ , for any “ _x_ ” not │ │ │ listed above │ └────────┴────────────────────────────┘ You can set the prompt in several ways: • _Use an environment variable._ You can set the MYSQL_PS1 environment variable to a prompt string. For example: shell> **export MYSQL_PS1="(\u@\h) [\d] > "** • _Use a command-line option._ You can set the **--prompt** option on the command line to **mariadb**. For example: shell> **mariadb --prompt="(\u@\h) [\d] > "** (user@host) [database]> • _Use an option file._ You can set the prompt option in the [mariadb] group of any MariaDB option file, such as /etc/my.cnf or the .my.cnf file in your home directory. For example: [mariadb] prompt=(\\u@\\h) [\\d]>\\_ In this example, note that the backslashes are doubled. If you set the prompt using the prompt option in an option file, it is advisable to double the backslashes when using the special prompt options. There is some overlap in the set of allowable prompt options and the set of special escape sequences that are recognized in option files. The overlap may cause you problems if you use single backslashes. For example, \s is interpreted as a space rather than as the current seconds value. The following example shows how to define a prompt within an option file to include the current time in HH:MM:SS> format: [mariadb] prompt="\\r:\\m:\\s> " • _Set the prompt interactively._ You can change your prompt interactively by using the prompt (or \R) command. For example: mariadb> **prompt (\u@\h) [\d] >\_** PROMPT set to '(\u@\h) [\d]>\_' (_user_ @_host_) [_database_]> (_user_ @_host_) [_database_]> prompt Returning to default PROMPT of mariadb> mariadb> ## MARIADB SERVER-SIDE HELP mariadb> **help** _search_string_ If you provide an argument to the help command, **mariadb** uses it as a search string to access server-side help. The proper operation of this command requires that the help tables in the mysql database be initialized with help topic information. If there is no match for the search string, the search fails: mariadb> **help me** Nothing found Please try to run 'help contents' for a list of all accessible topics Use **help contents** to see a list of the help categories: mariadb> **help contents** You asked for help about help category: "Contents" For more information, type 'help <item>', where <item> is one of the following categories: Account Management Administration Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Language Structure Plugins Storage Engines Stored Routines Table Maintenance Transactions Triggers If the search string matches multiple items, **mariadb** shows a list of matching topics: mariadb> **help logs** Many help items for your request exist. To make a more specific request, please type 'help <item>', where <item> is one of the following topics: SHOW SHOW BINARY LOGS SHOW ENGINE SHOW LOGS Use a topic as the search string to see the help entry for that topic: mariadb> **help show binary logs** Name: 'SHOW BINARY LOGS' Description: Syntax: SHOW BINARY LOGS SHOW MASTER LOGS Lists the binary log files on the server. This statement is used as part of the procedure described in [purge-binary-logs], that shows how to determine which logs can be purged. mariadb> SHOW BINARY LOGS; +---------------+-----------+ | Log_name | File_size | +---------------+-----------+ | binlog.000015 | 724935 | | binlog.000016 | 733481 | +---------------+-----------+ ## EXECUTING SQL STATEMENTS FROM A TEXT FILE The **mariadb** client typically is used interactively, like this: shell> **mariadb** _db_name_ However, it is also possible to put your SQL statements in a file and then tell **mariadb** to read its input from that file. To do so, create a text file _text_file_ that contains the statements you wish to execute. Then invoke **mariadb** as shown here: shell> **mariadb** _db_name_ **< **_text_file_ If you place a USE _db_name_ statement as the first statement in the file, it is unnecessary to specify the database name on the command line: shell> **mariadb < text_file** If you are already running **mariadb** , you can execute an SQL script file using the source command or \. command: mariadb> **source** _file_name_ mariadb> **\.**_file_name_ Sometimes you may want your script to display progress information to the user. For this you can insert statements like this: SELECT '<info_to_display>' AS ' '; The statement shown outputs <info_to_display>. You can also invoke **mariadb** with the **--verbose** option, which causes each statement to be displayed before the result that it produces. **mariadb** ignores Unicode byte order mark (BOM) characters at the beginning of input files. Presence of a BOM does not cause **mariadb** to change its default character set. To do that, invoke **mariadb** with an option such as **--default-character-set=utf8**. ## MARIADB TIPS This section describes some techniques that can help you use **mariadb** more effectively. **Displaying Query Results Vertically** Some query results are much more readable when displayed vertically, instead of in the usual horizontal table format. Queries can be displayed vertically by terminating the query with \G instead of a semicolon. For example, longer text values that include newlines often are much easier to read with vertical output: mariadb> **SELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\G** *************************** 1. row *************************** msg_nro: 3068 date: 2000-03-01 23:29:50 time_zone: +0200 mail_from: Monty reply: [email protected] mail_to: "Thimble Smith" <[email protected]> sbj: UTF-8 txt: >>>>> "Thimble" == Thimble Smith writes: Thimble> Hi. I think this is a good idea. Is anyone familiar Thimble> with UTF-8 or Unicode? Otherwise, I'll put this on my Thimble> TODO list and see what happens. Yes, please do that. Regards, Monty file: inbox-jani-1 hash: 190402944 1 row in set (0.09 sec) **Using the --safe-updates Option** For beginners, a useful startup option is **--safe-updates**(or **--i-am-a-dummy** , which has the same effect). It is helpful for cases when you might have issued a DELETE FROM _tbl_name_ statement but forgotten the WHERE clause. Normally, such a statement deletes all rows from the table. With **--safe-updates** , you can delete rows only by specifying the key values that identify them. This helps prevent accidents. When you use the **--safe-updates** option, **mariadb** issues the following statement when it connects to the MariaDB server: SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000; The SET statement has the following effects: • You are not allowed to execute an UPDATE or DELETE statement unless you specify a key constraint in the WHERE clause or provide a LIMIT clause (or both). For example: UPDATE _tbl_name_ SET _not_key_column_ =_val_ WHERE _key_column_ =_val_ ; UPDATE _tbl_name_ SET _not_key_column_ =_val_ LIMIT 1; • The server limits all large SELECT results to 1,000 rows unless the statement includes a LIMIT clause. • The server aborts multiple-table SELECT statements that probably need to examine more than 1,000,000 row combinations. To specify limits different from 1,000 and 1,000,000, you can override the defaults by using the **--select-limit** and **--max-join-size** options: shell> **mariadb --safe-updates --select-limit=500 --max-join-size=10000** **Disabling mariadb Auto-Reconnect** If the **mariadb** client loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again. However, even if **mariadb** succeeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user-defined and session variables. Also, any current transaction rolls back. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it: mariadb> **SET @a=1;** Query OK, 0 rows affected (0.05 sec) mariadb> **INSERT INTO t VALUES(@a);** ERROR 2006: MariaDB server has gone away No connection. Trying to reconnect... Connection id: 1 Current database: test Query OK, 1 row affected (1.30 sec) mariadb> **SELECT * FROM t;** +------+ | a | +------+ | NULL | +------+ 1 row in set (0.05 sec) The @a user variable has been lost with the connection, and after the reconnection it is undefined. If it is important to have **mariadb** terminate with an error if the connection has been lost, you can start the **mariadb** client with the **--skip-reconnect** option. ## NOTES 1. Bug#25946 http://bugs.mysql.com/bug.php?id=25946 * * *
# pmdatxmon ## NAME **pmdatxmon** , **txrecord** , **genload** - txmon performance metrics domain agent (PMDA) ## SYNOPSIS **$PCP_PMDAS_DIR/txmon/pmdatxmon**[**-D** _debug_] [**-d** _domain_] [**-l** _logfile_] [**-U** _username_] _tx_type_ ... **$PCP_PMDAS_DIR/txmon/txrecord**[**-l**] **$PCP_PMDAS_DIR/txmon/txrecord** _tx_type servtime_ [_tx_type servtime_ ... ] **$PCP_PMDAS_DIR/txmon/genload** ## DESCRIPTION **pmdatxmon** is an example Performance Metrics Domain Agent (PMDA) which exports a small number of performance metrics from a simulated transaction monitor. The txmon PMDA is shipped as both binary and source code and is designed to be an aid for PMDA developers; the txmon PMDA demonstrates how performance data can be exported from an application (in this case **txrecord**) to the PCP infrastructure via a shared memory segment. As a matter of convenience, **pmdatxmon** creates (and destroys on exit) the shared memory segment. The _tx_type_ arguments are arbitrary unique tags used to identify different transaction types. The **txrecord** application simulates the processing of one or more transactions identified by _tx_type_ and with an observed service time of _servtime ._ With the **-l** option, **txrecord** displays the current summary of the transaction activity from the shared memory segment. **genload** is a shell and **awk**(1) script that acts as a front-end to **txrecord** to generate a constant load of simulated transaction activity. A brief description of the **pmdatxmon** command line options follows: **-d** It is absolutely crucial that the performance metrics _domain_ number specified here is unique and consistent. That is, _domain_ should be different for every PMDA on the one host, and the same _domain_ number should be used for the same PMDA on all hosts. **-l** Location of the log file. By default, a log file named _txmon.log_ is written in the current directory of pmcd(1) when **pmdatxmon** is started, i.e. **$PCP_LOG_DIR/pmcd**. If the log file cannot be created or is not writable, output is written to the standard error instead. **-U** User account under which to run the agent. The default is the unprivileged "pcp" account in current versions of PCP, but in older versions the superuser account ("root") was used by default. ## INSTALLATION If you want access to the names, help text and values for the txmon performance metrics, do the following as root: # cd $PCP_PMDAS_DIR/txmon # ./Install You will be prompted for the _tx_type_ tags. If you want to undo the installation, do the following as root: # cd $PCP_PMDAS_DIR/txmon # ./Remove **pmdatxmon** is launched by pmcd(1) and should never be executed directly. The Install and Remove scripts notify pmcd(1) when the agent is installed or removed. ## FILES **$PCP_PMCDCONF_PATH** command line options used to launch **pmdatxmon** **$PCP_PMDAS_DIR/txmon/help** default help text file for the txmon metrics **$PCP_PMDAS_DIR/txmon/Install** installation script for the **pmdatxmon** agent **$PCP_PMDAS_DIR/txmon/Remove** undo installation script for the **pmdatxmon** agent **$PCP_LOG_DIR/pmcd/txmon.log** default log file for error messages and other information from **pmdatxmon** ## PCP ENVIRONMENT Environment variables with the prefix **PCP_** are used to parameterize the file and directory names used by PCP. On each installation, the file **/etc/pcp.conf** contains the local values for these variables. The **$PCP_CONF** variable may be used to specify an alternative configuration file, as described in pcp.conf(5). ## DEBUGGING OPTIONS The **-D** or **--debug** option enables the output of additional diagnostics on _stderr_ to help triage problems, although the information is sometimes cryptic and primarily intended to provide guidance for developers rather end-users. _debug_ is a comma separated list of debugging options; use pmdbg(1) with the **-l** option to obtain a list of the available debugging options and their meaning. Debugging options specific to **pmdatxmon** are as follows: ┌────────┬──────────────────────────┐ │ **Option** │ **Description** │ ├────────┼──────────────────────────┤ │ **appl0** │ shared memory operations │ └────────┴──────────────────────────┘ * * *
# babeltrace2-run ## NAME babeltrace2-run - Create a Babeltrace 2 trace processing graph and run it ## SYNOPSIS **babeltrace2**[_GENERAL OPTIONS_] **run**[**--retry-duration** =_TIME-US_] [**--allowed-mip-versions** =_VERSION_] **--connect** =_CONN-RULE_... _COMPONENTS_ ## DESCRIPTION The **run** command creates a Babeltrace 2 trace processing graph and runs it. See babeltrace2-intro(7) to learn more about the Babeltrace 2 project and its core concepts. The **run** command dynamically loads Babeltrace 2 plugins which supply component classes. With the **run** command, you specify which component classes to instantiate as components and how to connect them. The steps to write a **babeltrace2 run** command line are: 1. Specify which component classes to instantiate as components with many **--component** options and how to configure them. This is the _COMPONENTS_ part of the synopsis. See “Create components” to learn more. 2. Specify how to connect components together with one or more **--connect** options. See “Connect components” to learn more. **Note** The babeltrace2-convert(1) command is a specialization of the **run** command for the very common case of converting one or more traces: it generates a **run** command line and executes it. You can use its **--run-args** or **--run-args-0** option to make it print the equivalent **run** command line instead. **Create components** To create a component, use the **--component** option. This option specifies: • The name of the component, unique amongst all the component names of the trace processing graph. • The type of the component class to instantiate: source, filter, or sink. • The name of the plugin in which to find the component class to instantiate. • The name of the component class to instantiate. Use the **--component** option multiple times to create multiple components. You can instantiate the same component class multiple times as different components. At any point in the command line, the **--base-params** sets the current base initialization parameters and the **--reset-base-params** resets them. When you specify a **--component** option, its initial initialization parameters are a copy of the current base initialization parameters. Immediately following a **--component** option on the command line, the created component is known as the _current component_ (until the next **--component** option). The **--params** =_PARAMS_ option adds parameters to the initialization parameters of the current component. If _PARAMS_ contains a key which exists in the initialization parameters of the current component, then this parameter is replaced. **Connect components** The components which you create from component classes with the **--component** option (see “Create components”) add input and output _ports_ depending on their type. An output port is from where messages, like trace events, are sent. An input port is where messages are received. For a given component, each port has a unique name. The purpose of the **run** command is to create a trace processing graph, that is, to know which component ports to connect together. The command achieves this with the help of the connection rules that you provide with one or more **--connect** =_CONN-RULE_ options. The format of _CONN-RULE_ is: _UP-COMP-PAT_[._UP-PORT-PAT_]:_DOWN-COMP-PAT_[._DOWN-PORT-PAT_] _UP-COMP-PAT_ Upstream component name pattern. _UP-PORT-PAT_ Upstream (output) port name pattern. _DOWN-COMP-PAT_ Downstream component name pattern. _DOWN-PORT-PAT_ Downstream (input) port name pattern. When a source or filter component adds a new output port within the processing graph, the **run** command does the following to find an input port to connect it to: For each connection rule (--connect options, in order): If the component name of the output port matches UP-COMP-PAT and the output port name matches UP-PORT-PAT: For each component COMP in the trace processing graph: If the name of COMP matches DOWN-COMP-PAT: Select the first input port of COMP of which the name matches DOWN-PORT-PAT, or fail with no match. No possible connection: fail with no match. _UP-COMP-PAT_ , _UP-PORT-PAT_ , _DOWN-COMP-PAT_ , and _DOWN-PORT-PAT_ are globbing patterns where only the wildcard character, ***** , is special: it matches zero or more characters. You must escape the ***** , **?** , **[** , **.** , **:** , and **\** characters with **\**. When you don’t specify _UP-PORT-PAT_ or _DOWN-PORT-PAT_ , they’re equivalent to *****. You can leverage this connection mechanism to specify fallbacks with a careful use of wildcards, as the order of the **--connect** options on the command line is significant. For example: --connect='A.out*:B.in*' --connect=A:B --connect='*:C' With those connection rules, the **run** command connects: • Any output port of which the name starts with **out** of component **A** to the first input port of which the name starts with **in** of component **B**. • Any other output port of component **A** to the first available input port of component **B**. • Any other output port (of any component except **A**) to the first available input port of component **C**. The **run** command fails when it cannot find an input port to which to connect a given output port using the provided connection rules. See “EXAMPLES” for more examples. ## OPTIONS **General** You can use those options before the command name. See babeltrace2(1) for more details. **-d** , **--debug** Legacy option: this is equivalent to **--log-level** =**TRACE**. **-l** _LVL_ , **--log-level** =_LVL_ Set the log level of all known Babeltrace 2 loggers to _LVL_. **--omit-home-plugin-path** Don’t search for plugins in **$HOME/.local/lib/babeltrace2/plugins**. **--omit-system-plugin-path** Don’t search for plugins in **/usr/local/lib/babeltrace2/plugins**. **--plugin-path** =_PATH_[:_PATH_]... Add _PATH_ to the list of paths in which plugins can be found. **-v** , **--verbose** Legacy option: this is equivalent to **--log-level** =**INFO**. **Component creation** See “Create components” for more details. **-b** _PARAMS_ , **--base-params** =_PARAMS_ Set the current base parameters to _PARAMS_. You can reset the current base parameters with the **--reset-** **base-params** option. See the **--params** option for the format of _PARAMS_. **-c** _NAME_ :_COMP-CLS-TYPE_._PLUGIN-NAME_._COMP-CLS-NAME_ , **--component** =_NAME_ :_COMP-CLS-TYPE_._PLUGIN-NAME_._COMP-CLS-NAME_ Create a component named _NAME_ from the component class of type _COMP-CLS-TYPE_ named _COMP-CLS-NAME_ found in the plugin named _PLUGIN-NAME_ , and set it as the current component. The available values for _TYPE_ are: **source** , **src** Source component class. **filter** , **flt** Filter component class. **sink** Sink component class. The initial initialization parameters of this component are copied from the current base initialization parameters (see the **--base-params** option). **-l** _LVL_ , **--log-level** =_LVL_ Set the log level of the current component to _LVL_. The available values for _LVL_ are: **NONE** , **N** Logging is disabled. **FATAL** , **F** Severe errors that lead the execution to abort immediately. This level should be enabled in production. **ERROR** , **E** Errors that might still allow the execution to continue. Usually, once one or more errors are reported at this level, the application, plugin, or library won’t perform any more useful task, but it should still exit cleanly. This level should be enabled in production. **WARN** , **WARNING** , **W** Unexpected situations which still allow the execution to continue. This level should be enabled in production. **INFO** , **I** Informational messages that highlight progress or important states of the application, plugins, or library. This level can be enabled in production. **DEBUG** , **D** Debugging information, with a higher level of details than the **TRACE** level. This level should NOT be enabled in production. **TRACE** , **T** Low-level debugging context information. This level should NOT be enabled in production. **-p** _PARAMS_ , **--params** =_PARAMS_ Add _PARAMS_ to the initialization parameters of the current component. If _PARAMS_ contains a key which exists in the initialization parameters of the current component, then replace the parameter. The format of _PARAMS_ is a comma-separated list of _NAME_ =_VALUE_ assignments: _NAME_ =_VALUE_[,_NAME_ =_VALUE_]... _NAME_ Parameter name (C identifier plus the **:** , **.** , and **-** characters). _VALUE_ One of: • **null** , **nul** , **NULL** : null value. • **true** , **TRUE** , **yes** , **YES** : true boolean value. • **false** , **FALSE** , **no** , **NO** : false boolean value. • Binary (**0b** prefix), octal (**0** prefix), decimal, or hexadecimal (**0x** prefix) unsigned (with **+** prefix) or signed 64-bit integer. • Double precision floating point number (scientific notation is accepted). • Unquoted string with no special characters, and not matching any of the null and boolean value symbols above. • Double-quoted string (accepts escape characters). • Array, formatted as an opening **[** , a comma-separated list of _VALUE_ , and a closing **]**. • Map, formatted as an opening **{** , a comma-separated list of _NAME_ =_VALUE_ assignments, and a closing **}**. You may put whitespaces around the individual **=** (assignment), **,**(separator), **[**(array beginning), **]**(array end), **{**(map beginning), and **}**(map end) characters. Example: --params='many=null, fresh=yes, condition=false, squirrel=-782329, play=+23, observe=3.14, simple=beef, needs-quotes="some string", escape.chars-are:allowed="a \" quote", things=[1, "hello", 2.71828], frog={slow=2, bath=[bike, 23], blind=NO}' **Important** Like in the example above, make sure to single-quote the whole argument when you run this command from a shell, as it can contain many special characters. **-r** , **--reset-base-params** Reset the current base parameters. You can set the current base parameters with the **--base-params** option. **Component connection** **-x** _CONN-RULE_ , **--connect** =_CONN-RULE_ Add the connection rule _CONN-RULE_. The format of _CONN-RULE_ is: _UP-COMP-PAT_[._UP-PORT-PAT_]:_DOWN-COMP-PAT_[._DOWN-PORT-PAT_] _UP-COMP-PAT_ Upstream component name pattern. _UP-PORT-PAT_ Upstream (output) port name pattern. _DOWN-COMP-PAT_ Downstream component name pattern. _DOWN-PORT-PAT_ Downstream (input) port name pattern. See “Connect components” to learn more. **Graph configuration** **-m** _VERSION_ , **--allowed-mip-versions** =_VERSION_ Only allow the graph to honour version _VERSION_ (0 or 1) of the Message Interchange Protocol (MIP) instead of allowing both versions. **--retry-duration** =_TIME-US_ Set the duration of a single retry to _TIME-US_ µs when a sink component reports "try again later" (busy network or file system, for example). Default: 100000 (100 ms). **Command information** **-h** , **--help** Show the command help and quit. ## EXAMPLES **Example 1. Create a single-port source component and a single-port** **sink component and connect them.** $ babeltrace2 run --component=A:src.plug.my-src \ --component=B:sink.plug.my-sink \ --connect=A:B Possible resulting graph: +-----------------+ +-------------------+ | src.plug.my-src | | sink.plug.my-sink | | [A] | | [B] | | | | | | out @--->@ in | +-----------------+ +-------------------+ **Example 2. Use the --params option to set the initialization** **parameters of the current component.** In this example, the **--params** option only applies to component **the-source**. $ babeltrace2 run --component=the-source:src.my-plugin.my-src \ --params=offset=123,flag=true \ --component=the-sink:sink.my-plugin.my-sink \ --connect=the-source:the-sink **Example 3. Use the --base-params and --reset-base-params options** **to set and reset the current base initialization parameters.** In this example, the effective initialization parameters of the created components are: Component **A** **offset=1203, flag=false** Component **B** **offset=1203, flag=true, type=event** Component **C** **ratio=0.25** $ babeltrace2 run --base-params=offset=1203,flag=false \ --component=A:src.plugin.compcls \ --component=B:flt.plugin.compcls \ --params=flag=true,type=event \ --reset-base-params \ --component=C:sink.plugin.compcls \ --params=ratio=0.25 \ --connect=A:B --connect=B:C **Example 4. Specify a component connection fallback rule.** In this example, any **A** output port of which the name starts with **foo** is connected to a **B** input port of which the name starts with **nin**. Any other **A** output port is connected to a **B** input port of which the name starts with **oth**. The order of the **--connect** options is important here: the opposite order would create a system in which the first rule is always satisfied, and _any_ **A** output port, whatever its name, would be connected to a **B** input port with a name that starts with **oth**. $ babeltrace2 run --component=A:src.plug.my-src \ --component=B:sink.plug.my-sink \ --connect='A.foo*:B:nin*' --connect='A:B.oth*' Possible resulting graph: +-----------------+ +-------------------+ | src.plug.my-src | | sink.plug.my-sink | | [A] | | [B] | | | | | | foot @--->@ nine | | foodies @--->@ ninja | | some-port @--->@ othello | | hello @--->@ other | +-----------------+ +-------------------+ ## ENVIRONMENT VARIABLES **Babeltrace 2 library** **BABELTRACE_EXEC_ON_ABORT** =_CMDLINE_ Execute the command line _CMDLINE_ , as parsed like a UNIX 98 shell, when any part of the Babeltrace 2 project unexpectedly aborts. The application only aborts when the executed command returns, ignoring its exit status. This environment variable is ignored when the application has the **setuid** or the **setgid** access right flag set. **BABELTRACE_TERM_COLOR** =(**AUTO** | **NEVER** | **ALWAYS**) Force the terminal color support for the babeltrace2(1) program and the project plugins. The available values are: **AUTO** Only emit terminal color codes when the standard output and error streams are connected to a color-capable terminal. **NEVER** Never emit terminal color codes. **ALWAYS** Always emit terminal color codes. **BABELTRACE_TERM_COLOR_BRIGHT_MEANS_BOLD** =**0** Set to **0** to emit SGR (see <https://en.wikipedia.org/wiki/ANSI_escape_code>) codes 90 to 97 for bright colors instead of bold (SGR code 1) and standard color codes (SGR codes 30 to 37). **BABELTRACE_PLUGIN_PATH** =_PATHS_ Set the list of directories, in order, in which dynamic plugins can be found before other directories are considered to _PATHS_ (colon-separated, or semicolon on Windows). **LIBBABELTRACE2_DISABLE_PYTHON_PLUGINS** =**1** Disable the loading of any Babeltrace 2 Python plugin. **LIBBABELTRACE2_INIT_LOG_LEVEL** =_LVL_ Force the initial log level of the Babeltrace 2 library to be _LVL_. If this environment variable is set, then it overrides the log level set by the **--log-level** option for the Babeltrace 2 library logger. The available values for _LVL_ are: **NONE** , **N** Logging is disabled. **FATAL** , **F** Severe errors that lead the execution to abort immediately. This level should be enabled in production. **ERROR** , **E** Errors that might still allow the execution to continue. Usually, once one or more errors are reported at this level, the application, plugin, or library won’t perform any more useful task, but it should still exit cleanly. This level should be enabled in production. **WARN** , **WARNING** , **W** Unexpected situations which still allow the execution to continue. This level should be enabled in production. **INFO** , **I** Informational messages that highlight progress or important states of the application, plugins, or library. This level can be enabled in production. **DEBUG** , **D** Debugging information, with a higher level of details than the **TRACE** level. This level should NOT be enabled in production. **TRACE** , **T** Low-level debugging context information. This level should NOT be enabled in production. **LIBBABELTRACE2_NO_DLCLOSE** =**1** Make the Babeltrace 2 library leave any dynamically loaded modules (plugins and plugin providers) open at exit. This can be useful for debugging purposes. **LIBBABELTRACE2_PLUGIN_PROVIDER_DIR** =_DIR_ Set the directory from which the Babeltrace 2 library dynamically loads plugin provider shared objects to _DIR_. If this environment variable is set, then it overrides the default plugin provider directory. **Babeltrace 2 Python bindings** **BABELTRACE_PYTHON_BT2_LOG_LEVEL** =_LVL_ Force the Babeltrace 2 Python bindings log level to be _LVL_. If this environment variable is set, then it overrides the log level set by the **--log-level** option for the Python bindings logger. The available values for _LVL_ are: **NONE** , **N** Logging is disabled. **FATAL** , **F** Severe errors that lead the execution to abort immediately. This level should be enabled in production. **ERROR** , **E** Errors that might still allow the execution to continue. Usually, once one or more errors are reported at this level, the application, plugin, or library won’t perform any more useful task, but it should still exit cleanly. This level should be enabled in production. **WARN** , **WARNING** , **W** Unexpected situations which still allow the execution to continue. This level should be enabled in production. **INFO** , **I** Informational messages that highlight progress or important states of the application, plugins, or library. This level can be enabled in production. **DEBUG** , **D** Debugging information, with a higher level of details than the **TRACE** level. This level should NOT be enabled in production. **TRACE** , **T** Low-level debugging context information. This level should NOT be enabled in production. **CLI** **BABELTRACE_CLI_LOG_LEVEL** =_LVL_ Force the log level of the log level **babeltrace2** CLI to be _LVL_. If this environment variable is set, then it overrides the log level set by the **--log-level** option for the CLI logger. The available values for _LVL_ are: **NONE** , **N** Logging is disabled. **FATAL** , **F** Severe errors that lead the execution to abort immediately. This level should be enabled in production. **ERROR** , **E** Errors that might still allow the execution to continue. Usually, once one or more errors are reported at this level, the application, plugin, or library won’t perform any more useful task, but it should still exit cleanly. This level should be enabled in production. **WARN** , **WARNING** , **W** Unexpected situations which still allow the execution to continue. This level should be enabled in production. **INFO** , **I** Informational messages that highlight progress or important states of the application, plugins, or library. This level can be enabled in production. **DEBUG** , **D** Debugging information, with a higher level of details than the **TRACE** level. This level should NOT be enabled in production. **TRACE** , **T** Low-level debugging context information. This level should NOT be enabled in production. **BABELTRACE_CLI_WARN_COMMAND_NAME_DIRECTORY_CLASH** =**0** Disable the warning message which babeltrace2-convert(1) prints when you convert a trace with a relative path that’s also the name of a **babeltrace2** command. **BABELTRACE_DEBUG** =**1** Legacy variable: equivalent to setting the **--log-level** option to **TRACE**. **BABELTRACE_VERBOSE** =**1** Legacy variable: equivalent to setting the **--log-level** option to **INFO**. ## FILES **$HOME/.local/lib/babeltrace2/plugins** User plugin directory. **/usr/local/lib/babeltrace2/plugins** System plugin directory. **/usr/local/lib/babeltrace2/plugin-providers** System plugin provider directory. ## EXIT STATUS **0** on success, **1** otherwise. ## BUGS If you encounter any issue or usability problem, please report it on the Babeltrace bug tracker (see <https://bugs.lttng.org/projects/babeltrace>). ## RESOURCES The Babeltrace project shares some communication channels with the LTTng project (see <https://lttng.org/>). • Babeltrace website (see <https://babeltrace.org/>) • Mailing list (see <https://lists.lttng.org>) for support and development: **[email protected]** • IRC channel (see <irc://irc.oftc.net/lttng>): **#lttng** on **irc.oftc.net** • Bug tracker (see <https://bugs.lttng.org/projects/babeltrace>) • Git repository (see <https://git.efficios.com/?p=babeltrace.git>) • GitHub project (see <https://github.com/efficios/babeltrace>) • Continuous integration (see <https://ci.lttng.org/view/Babeltrace/>) • Code review (see <https://review.lttng.org/q/project:babeltrace>) * * *
# opgprof ## NAME opgprof - produce gprof-format profile data ## SYNOPSIS **opgprof**[ _options_ ] [profile specification] ## DESCRIPTION **opgprof** outputs gprof-format profile data for a given binary image, from an OProfile session. See oprofile(1) for how to write profile specifications. ## OPTIONS **--help / -? / --usage** Show help message. **--version / -v** Show version. **--verbose / -V [options]** Give verbose debugging output. **--session-dir=**_dir_path_ Use sample database from the specified directory _dir_path_ instead of the default location. If _--session-dir_ is not specified, then **opgprof** will search for samples in <current_dir>/oprofile_data first. If that directory does not exist, the standard session-dir of /var/lib/oprofile is used. **--image-path / -p [paths]** Comma-separated list of additional paths to search for binaries. This is needed to find modules in kernels 2.6 and upwards. **--root / -R [path]** A path to a filesystem to search for additional binaries. **--threshold / -t [percentage]** Only output data for symbols that have more than the given percentage of total samples. **--output-filename / -o [file]** Output to the given file instead of the default, gmon.out ## ENVIRONMENT No special environment variables are recognized by opgprof. ## FILES _< session_dir>/samples_ The location of the generated sample files. ## VERSION This man page is current for oprofile-1.5.0git. * * *
# tset ## NAME **tset** , **reset** - terminal initialization ## SYNOPSIS **tset**[**-IQVcqrsw**] [**-**] [**-e** _ch_] [**-i** _ch_] [**-k** _ch_] [**-m** _mapping_] [_terminal_] **reset**[**-IQVcqrsw**] [**-**] [**-e** _ch_] [**-i** _ch_] [**-k** _ch_] [**-m** _mapping_] [_terminal_] ## DESCRIPTION **tset - initialization** This program initializes terminals. First, **tset** retrieves the current terminal mode settings for your terminal. It does this by successively testing • the standard error, • standard output, • standard input and • ultimately “/dev/tty” to obtain terminal settings. Having retrieved these settings, **tset** remembers which file descriptor to use when updating settings. Next, **tset** determines the type of terminal that you are using. This determination is done as follows, using the first terminal type found. 1. The **terminal** argument specified on the command line. 2. The value of the **TERM** environmental variable. 3. (BSD systems only.) The terminal type associated with the standard error output device in the _/etc/ttys_ file. (On System-V- like UNIXes and systems using that convention, **getty**(1) does this job by setting **TERM** according to the type passed to it by _/etc/inittab_.) 4. The default terminal type, “unknown”. If the terminal type was not specified on the command-line, the **-m** option mappings are then applied (see the section **TERMINAL TYPE** **MAPPING** for more information). Then, if the terminal type begins with a question mark (“?”), the user is prompted for confirmation of the terminal type. An empty response confirms the type, or, another type can be entered to specify a new type. Once the terminal type has been determined, the terminal description for the terminal is retrieved. If no terminal description is found for the type, the user is prompted for another terminal type. Once the terminal description is retrieved, • if the “**-w** ” option is enabled, **tset** may update the terminal's window size. If the window size cannot be obtained from the operating system, but the terminal description (or environment, e.g., **LINES** and **COLUMNS** variables specify this), use this to set the operating system's notion of the window size. • if the “**-c** ” option is enabled, the backspace, interrupt and line kill characters (among many other things) are set • unless the “**-I** ” option is enabled, the terminal and tab _initialization_ strings are sent to the standard error output, and **tset** waits one second (in case a hardware reset was issued). • Finally, if the erase, interrupt and line kill characters have changed, or are not set to their default values, their values are displayed to the standard error output. **reset - reinitialization** When invoked as **reset** , **tset** sets the terminal modes to “sane” values: • sets cooked and echo modes, • turns off cbreak and raw modes, • turns on newline translation and • resets any unset special characters to their default values before doing the terminal initialization described above. Also, rather than using the terminal _initialization_ strings, it uses the terminal _reset_ strings. The **reset** command is useful after a program dies leaving a terminal in an abnormal state: • you may have to type _< LF>_**reset** _< LF>_ (the line-feed character is normally control-J) to get the terminal to work, as carriage-return may no longer work in the abnormal state. • Also, the terminal will often not echo the command. ## OPTIONS The options are as follows: **-c** Set control characters and modes. **-e** _ch_ Set the erase character to _ch_. **-I** Do not send the terminal or tab initialization strings to the terminal. **-i** _ch_ Set the interrupt character to _ch_. **-k** _ch_ Set the line kill character to _ch_. **-m** _mapping_ Specify a mapping from a port type to a terminal. See the section **TERMINAL TYPE MAPPING** for more information. **-Q** Do not display any values for the erase, interrupt and line kill characters. Normally **tset** displays the values for control characters which differ from the system's default values. **-q** The terminal type is displayed to the standard output, and the terminal is not initialized in any way. The option “-” by itself is equivalent but archaic. **-r** Print the terminal type to the standard error output. **-s** Print the sequence of shell commands to initialize the environment variable **TERM** to the standard output. See the section **SETTING THE ENVIRONMENT** for details. **-V** reports the version of ncurses which was used in this program, and exits. **-w** Resize the window to match the size deduced via **setupterm**(3X). Normally this has no effect, unless **setupterm** is not able to detect the window size. The arguments for the **-e** , **-i** , and **-k** options may either be entered as actual characters or by using the “hat” notation, i.e., control-h may be specified as “^H” or “^h”. If neither **-c** or **-w** is given, both options are assumed. ## SETTING THE ENVIRONMENT It is often desirable to enter the terminal type and information about the terminal's capabilities into the shell's environment. This is done using the **-s** option. When the **-s** option is specified, the commands to enter the information into the shell's environment are written to the standard output. If the **SHELL** environmental variable ends in “csh”, the commands are for **csh** , otherwise, they are for **sh**(1). Note, the **csh** commands set and unset the shell variable **noglob** , leaving it unset. The following line in the **.login** or **.profile** files will initialize the environment correctly: eval `tset -s options ... ` ## TERMINAL TYPE MAPPING When the terminal is not hardwired into the system (or the current system information is incorrect) the terminal type derived from the _/etc/ttys_ file or the **TERM** environmental variable is often something generic like **network** , **dialup** , or **unknown**. When **tset** is used in a startup script it is often desirable to provide information about the type of terminal used on such ports. The **-m** options maps from some set of conditions to a terminal type, that is, to tell **tset** “If I'm on this port at a particular speed, guess that I'm on that kind of terminal”. The argument to the **-m** option consists of an optional port type, an optional operator, an optional baud rate specification, an optional colon (“:”) character and a terminal type. The port type is a string (delimited by either the operator or the colon character). The operator may be any combination of “>”, “<”, “@”, and “!”; “>” means greater than, “<” means less than, “@” means equal to and “!” inverts the sense of the test. The baud rate is specified as a number and is compared with the speed of the standard error output (which should be the control terminal). The terminal type is a string. If the terminal type is not specified on the command line, the **-m** mappings are applied to the terminal type. If the port type and baud rate match the mapping, the terminal type specified in the mapping replaces the current type. If more than one mapping is specified, the first applicable mapping is used. For example, consider the following mapping: **dialup >9600:vt100**. The port type is dialup , the operator is >, the baud rate specification is 9600, and the terminal type is vt100. The result of this mapping is to specify that if the terminal type is **dialup** , and the baud rate is greater than 9600 baud, a terminal type of **vt100** will be used. If no baud rate is specified, the terminal type will match any baud rate. If no port type is specified, the terminal type will match any port type. For example, **-m dialup:vt100 -m :?xterm** will cause any dialup port, regardless of baud rate, to match the terminal type vt100, and any non-dialup port type to match the terminal type ?xterm. Note, because of the leading question mark, the user will be queried on a default port as to whether they are actually using an xterm terminal. No whitespace characters are permitted in the **-m** option argument. Also, to avoid problems with meta-characters, it is suggested that the entire **-m** option argument be placed within single quote characters, and that **csh** users insert a backslash character (“\”) before any exclamation marks (“!”). ## COMPATIBILITY Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor X/Open Curses Issue 7 documents **tset** or **reset**. The AT&T **tput** utility (AIX, HPUX, Solaris) incorporated the terminal-mode manipulation as well as termcap-based features such as resetting tabstops from **tset** in BSD (4.1c), presumably with the intention of making **tset** obsolete. However, each of those systems still provides **tset**. In fact, the commonly-used **reset** utility is always an alias for **tset**. The **tset** utility provides for backward-compatibility with BSD environments (under most modern UNIXes, **/etc/inittab** and **getty**(1) can set **TERM** appropriately for each dial-up line; this obviates what was **tset** 's most important use). This implementation behaves like 4.4BSD **tset** , with a few exceptions specified here. A few options are different because the **TERMCAP** variable is no longer supported under terminfo-based **ncurses** : • The **-S** option of BSD **tset** no longer works; it prints an error message to the standard error and dies. • The **-s** option only sets **TERM** , not **TERMCAP**. There was an undocumented 4.4BSD feature that invoking **tset** via a link named “TSET” (or via any other name beginning with an upper- case letter) set the terminal to use upper-case only. This feature has been omitted. The **-A** , **-E** , **-h** , **-u** and **-v** options were deleted from the **tset** utility in 4.4BSD. None of them were documented in 4.3BSD and all are of limited utility at best. The **-a** , **-d** , and **-p** options are similarly not documented or useful, but were retained as they appear to be in widespread use. It is strongly recommended that any usage of these three options be changed to use the **-m** option instead. The **-a** , **-d** , and **-p** options are therefore omitted from the usage summary above. Very old systems, e.g., 3BSD, used a different terminal driver which was replaced in 4BSD in the early 1980s. To accommodate these older systems, the 4BSD **tset** provided a **-n** option to specify that the new terminal driver should be used. This implementation does not provide that choice. It is still permissible to specify the **-e** , **-i** , and **-k** options without arguments, although it is strongly recommended that such usage be fixed to explicitly specify the character. As of 4.4BSD, executing **tset** as **reset** no longer implies the **-Q** option. Also, the interaction between the - option and the _terminal_ argument in some historic implementations of **tset** has been removed. The **-c** and **-w** options are not found in earlier implementations. However, a different window size-change feature was provided in 4.4BSD. • In 4.4BSD, **tset** uses the window size from the termcap description to set the window size if **tset** is not able to obtain the window size from the operating system. • In ncurses, **tset** obtains the window size using **setupterm** , which may be from the operating system, the **LINES** and **COLUMNS** environment variables or the terminal description. Obtaining the window size from the terminal description is common to both implementations, but considered obsolescent. Its only practical use is for hardware terminals. Generally speaking, a window size would be unset only if there were some problem obtaining the value from the operating system (and **setupterm** would still fail). For that reason, the **LINES** and **COLUMNS** environment variables may be useful for working around window-size problems. Those have the drawback that if the window is resized, those variables must be recomputed and reassigned. To do this more easily, use the **resize**(1) program. ## ENVIRONMENT The **tset** command uses these environment variables: SHELL tells **tset** whether to initialize **TERM** using **sh**(1) or **csh**(1) syntax. TERM Denotes your terminal type. Each terminal type is distinct, though many are similar. TERMCAP may denote the location of a termcap database. If it is not an absolute pathname, e.g., begins with a “/”, **tset** removes the variable from the environment before looking for the terminal description. ## FILES /etc/ttys system port name to terminal type mapping database (BSD versions only). terminfo terminal capability database * * *
# pmdaroomtemp ## NAME **pmdaroomtemp** - room temperature performance metrics domain agent (PMDA) ## SYNOPSIS **$PCP_PMDAS_DIR/roomtemp/pmdaroomtemp**[**-D** _debug_] [**-d** _domain_] [**-l** _logfile_] ## DESCRIPTION **pmdaroomtemp** is a Performance Metrics Domain Agent (PMDA) which exports the temperature from one or more sensors built using the DS2480 and DS1280 chipsets and MicroLAN technology from Dallas Semiconductor Corporation. The **roomtemp** PMDA exports metrics that reflect the temperatures from one or more of these devices, in both degrees Celsius and Fahrenheit. Each metric has one instance for each temperature sensor device. The external instance identifiers are the serial numbers (in hex) of the DS1280 chips discovered when the MicroLAN was probed. A brief description of the **pmdaroomtemp** command line options follows: **-d** It is absolutely crucial that the performance metrics _domain_ number specified here is unique and consistent. That is, _domain_ should be different for every PMDA on the one host, and the same _domain_ number should be used for the same PMDA on all hosts. **-l** Location of the log file. By default, a log file named _roomtemp.log_ is written in the current directory of pmcd(1) when **pmdaroomtemp** is started, i.e. **$PCP_LOG_DIR/pmcd**. If the log file cannot be created or is not writable, output is written to the standard error instead. ## INSTALLATION If you want access to the names, help text and values for the roomtemp performance metrics, do the following as root: # cd $PCP_PMDAS_DIR/roomtemp # ./Install If you want to undo the installation, do the following as root: # cd $PCP_PMDAS_DIR/roomtemp # ./Remove **pmdaroomtemp** is launched by pmcd(1) and should never be executed directly. The Install and Remove scripts notify pmcd(1) when the agent is installed or removed. ## FILES **$PCP_PMCDCONF_PATH** command line options used to launch **pmdaroomtemp** **$PCP_PMDAS_DIR/roomtemp/help** default help text file for the roomtemp metrics **$PCP_PMDAS_DIR/roomtemp/Install** installation script for the **pmdaroomtemp** agent **$PCP_PMDAS_DIR/roomtemp/Remove** undo installation script for the **pmdaroomtemp** agent **$PCP_LOG_DIR/pmcd/roomtemp.log** default log file for error messages and other information from **pmdaroomtemp** ## PCP ENVIRONMENT Environment variables with the prefix **PCP_** are used to parameterize the file and directory names used by PCP. On each installation, the file _/etc/pcp.conf_ contains the local values for these variables. The **$PCP_CONF** variable may be used to specify an alternative configuration file, as described in pcp.conf(5). ## DEBUGGING OPTIONS The **-D** or **--debug** option enables the output of additional diagnostics on _stderr_ to help triage problems, although the information is sometimes cryptic and primarily intended to provide guidance for developers rather end-users. _debug_ is a comma separated list of debugging options; use pmdbg(1) with the **-l** option to obtain a list of the available debugging options and their meaning. * * *
# lttng-disable-event ## NAME lttng-disable-event - Disable LTTng event rules ## SYNOPSIS **lttng**[_GENERAL OPTIONS_] **disable-event** (**--kernel**[**--probe** | **--function** | **--syscall**] | **--userspace** | **--jul** | **--log4j** | **--python**) [**--session** =_SESSION_] [**--channel** =_CHANNEL_] (**--all-events** | _EVENT_[,_EVENT_]...) ## DESCRIPTION The **lttng disable-event** command disables one or more event rules previously enabled by the lttng-enable-event(1) command. Event rules are always assigned to a channel when they are created. If the **--channel** option is omitted, the default channel named **channel0** is used. If the **--session** option is omitted, the chosen channel is picked from the current tracing session. If the **--all-events** option is used, all the existing event rules of the chosen domain are disabled. Otherwise, at least one event rule to disable named _EVENT_ must be specified. With the **--kernel** option, the event source type can be specified using one of the **--tracepoint** , **--probe** , **--function** , or **--syscall** options. See lttng-enable-event(1) for more details about event source types. Events can be disabled while tracing is active (use lttng-start(1) to make a tracing session active). ## OPTIONS General options are described in lttng(1). **Domain** One of: **-j** , **--jul** Disable event rules in the **java.util.logging**(JUL) domain. **-k** , **--kernel** Disable event rules in the Linux kernel domain. **-l** , **--log4j** Disable event rules in the Apache log4j domain. **-p** , **--python** Disable event rules in the Python domain. **-u** , **--userspace** Disable event rules in the user space domain. **Target** **-c** _CHANNEL_ , **--channel** =_CHANNEL_ Disable event rules in the channel named _CHANNEL_ instead of the default channel name **channel0**. **-s** _SESSION_ , **--session** =_SESSION_ Disable event rules in the tracing session named _SESSION_ instead of the current tracing session. **Event source type** One of: **--function** Linux kernel kretprobe. Only available with the **--kernel** domain option. **--probe** Linux kernel kprobe. Only available with the **--kernel** domain option. **--syscall** Linux kernel system call. Only available with the **--kernel** domain option. **--tracepoint** Linux kernel or application tracepoint. Only available with the **--kernel** domain option (default Linux kernel domain event source type). **Disabling** **-a** , **--all-events** Disable all enabled event rules in the chosen tracing session, tracing domain, and channel. **Program information** **-h** , **--help** Show command help. This option, like lttng-help(1), attempts to launch **/usr/bin/man** to view the command’s man page. The path to the man pager can be overridden by the **LTTNG_MAN_BIN_PATH** environment variable. **--list-options** List available command options. ## ENVIRONMENT VARIABLES **LTTNG_ABORT_ON_ERROR** Set to 1 to abort the process after the first error is encountered. **LTTNG_HOME** Overrides the **$HOME** environment variable. Useful when the user running the commands has a non-writable home directory. **LTTNG_MAN_BIN_PATH** Absolute path to the man pager to use for viewing help information about LTTng commands (using lttng-help(1) or **lttng** **COMMAND --help**). **LTTNG_SESSION_CONFIG_XSD_PATH** Path in which the **session.xsd** session configuration XML schema may be found. **LTTNG_SESSIOND_PATH** Full session daemon binary path. The **--sessiond-path** option has precedence over this environment variable. Note that the lttng-create(1) command can spawn an LTTng session daemon automatically if none is running. See lttng-sessiond(8) for the environment variables influencing the execution of the session daemon. ## FILES **$LTTNG_HOME/.lttngrc** User LTTng runtime configuration. This is where the per-user current tracing session is stored between executions of lttng(1). The current tracing session can be set with lttng-set-session(1). See lttng-create(1) for more information about tracing sessions. **$LTTNG_HOME/lttng-traces** Default output directory of LTTng traces. This can be overridden with the **--output** option of the lttng-create(1) command. **$LTTNG_HOME/.lttng** User LTTng runtime and configuration directory. **$LTTNG_HOME/.lttng/sessions** Default location of saved user tracing sessions (see lttng-save(1) and lttng-load(1)). **/usr/local/etc/lttng/sessions** System-wide location of saved tracing sessions (see lttng-save(1) and lttng-load(1)). **Note** **$LTTNG_HOME** defaults to **$HOME** when not explicitly set. ## EXIT STATUS **0** Success **1** Command error **2** Undefined command **3** Fatal error **4** Command warning (something went wrong during the command) ## BUGS If you encounter any issue or usability problem, please report it on the LTTng bug tracker <https://bugs.lttng.org/projects/lttng- tools>. ## RESOURCES • LTTng project website <https://lttng.org> • LTTng documentation <https://lttng.org/docs> • Git repositories <http://git.lttng.org> • GitHub organization <http://github.com/lttng> • Continuous integration <http://ci.lttng.org/> • Mailing list <http://lists.lttng.org> for support and development: **[email protected]** • IRC channel <irc://irc.oftc.net/lttng>: **#lttng** on **irc.oftc.net** ## THANKS Special thanks to Michel Dagenais and the DORSAL laboratory <http://www.dorsal.polymtl.ca/> at École Polytechnique de Montréal for the LTTng journey. Also thanks to the Ericsson teams working on tracing which helped us greatly with detailed bug reports and unusual test cases. * * *
# cifscreds ## NAME cifscreds - manage NTLM credentials in kernel keyring ## SYNOPSIS cifscreds add|clear|clearall|update [-u username] [-d] host|domain [-t timeout] ## DESCRIPTION The **cifscreds** program is a tool for managing credentials (username and password) for the purpose of establishing sessions in multiuser mounts. When a cifs filesystem is mounted with the "multiuser" option, and does not use krb5 authentication, it needs to be able to get the credentials for each user from somewhere. The **cifscreds** program is the tool used to provide these credentials to the kernel. The first non-option argument to cifscreds is a command (see the COMMANDS section below). The second non-option argument is a hostname or address, or an NT domain name. ## COMMANDS **add** Add credentials to the kernel to be used for connecting to the given server, or servers in the given domain. **clear** Clear credentials for a particular host or domain from the kernel. **clearall** Clear all cifs credentials from the kernel. **update** Update stored credentials in the kernel with a new username and password. ## OPTIONS **-d** , **--domain** The provided host/domain argument is a NT domainname. Ordinarily the second argument provided to cifscreds is treated as a hostname or IP address. This option causes the cifscreds program to treat that argument as an NT domainname instead. If there are not host specific credentials for the mounted server, then the kernel will next look for a set of domain credentials equivalent to the domain= option provided at mount time. **-u** , **--username** Ordinarily, the username is derived from the unix username of the user adding the credentials. This option allows the user to substitute a different username. **-t** , **--timeout** Sets the key timeout in seconds. If not set, will use the system default timeout for logon keys. ## NOTES The cifscreds utility requires a kernel built with support for the **login** key type. That key type was added in v3.3 in mainline Linux kernels. Since **cifscreds** adds keys to the session keyring, it is highly recommended that one use **pam_keyinit** to ensure that a session keyring is established at login time. * * *
# newrole ## NAME newrole - run a shell with a new SELinux role ## SYNOPSIS **newrole**[**-r** |**--role**] _ROLE_ [**-t** |**--type**] _TYPE_ [**-l** |**--level**] [**-p** |**--preserve-environment**] _LEVEL_ [-- [_ARGS_]...] ## DESCRIPTION Run a new shell in a new context. The new context is derived from the old context in which **newrole** is originally executed. If the **-r** or **--role** option is specified, then the new context will have the role specified by _ROLE_. If the **-t** or **--type** option is specified, then the new context will have the type (domain) specified by _TYPE_. If a role is specified, but no type is specified, the default type is derived from the specified role. If the **-l** or **--level** option is specified, then the new context will have the sensitivity level specified by _LEVEL_. If _LEVEL_ is a range, the new context will have the sensitivity level and clearance specified by that range. If the **-p** or **--preserve-** **environment** option is specified, the shell with the new SELinux context will preserve environment variables, otherwise a new minimal environment is created. Additional arguments _ARGS_ may be provided after a -- option, in which case they are supplied to the new shell. In particular, an argument of -- -c will cause the next argument to be treated as a command by most command interpreters. If a command argument is specified to newrole and the command name is found in /etc/selinux/newrole_pam.conf, then the pam service name listed in that file for the command will be used rather than the normal newrole pam configuration. This allows for per-command pam configuration when invoked via newrole, e.g. to skip the interactive re-authentication phase. The new shell will be the shell specified in the user's entry in the _/etc/passwd_ file. The **-V** or **--version** shows the current version of newrole ## EXAMPLE Changing role: # id -Z staff_u:staff_r:staff_t:SystemLow-SystemHigh # newrole -r sysadm_r # id -Z staff_u:sysadm_r:sysadm_t:SystemLow-SystemHigh Changing sensitivity only: # id -Z staff_u:sysadm_r:sysadm_t:Unclassified-SystemHigh # newrole -l Secret # id -Z staff_u:sysadm_r:sysadm_t:Secret-SystemHigh Changing sensitivity and clearance: # id -Z staff_u:sysadm_r:sysadm_t:Unclassified-SystemHigh # newrole -l Secret-Secret # id -Z staff_u:sysadm_r:sysadm_t:Secret Running a program in a given role or level: # newrole -r sysadm_r -- -c "/path/to/app arg1 arg2..." # newrole -l Secret -- -c "/path/to/app arg1 arg2..." ## FILES /etc/passwd - user account information /etc/shadow - encrypted passwords and age information /etc/selinux/<policy>/contexts/default_type - default types for roles /etc/selinux/<policy>/contexts/securetty_types - securetty types for level changes /etc/selinux/newrole_pam.conf - optional mapping of commands to separate pam service names * * *
# flatpak-build-sign ## NAME flatpak-build-sign - Sign an application or runtime ## SYNOPSIS **flatpak build-sign**[OPTION...] LOCATION ID [BRANCH] ## DESCRIPTION Signs the commit for a specified application or runtime in a local repository. LOCATION is the location of the repository. ID is the name of the application, or runtime if --runtime is specified. If BRANCH is not specified, it is assumed to be "master". Applications can also be signed during build-export, but it is sometimes useful to add additional signatures later. ## OPTIONS The following options are understood: **-h** , **--help** Show help options and exit. **--gpg-sign=KEYID** Sign the commit with this GPG key. This option can be used multiple times. **--gpg-homedir=PATH** GPG Homedir to use when looking for keyrings **--runtime** Sign a runtime instead of an app. **--arch=ARCH** The architecture to use. See **flatpak --supported-arches** for architectures supported by the host. **-v** , **--verbose** Print debug information during command processing. **--ostree-verbose** Print OSTree debug information during command processing. ## EXAMPLES **$ flatpak build-sign** **--gpg-sign=D8BA6573DDD2418027736F1BC33B315E53C1E9D6 /some/repo** **org.my.App** * * *
# git-am ## NAME git-am - Apply a series of patches from a mailbox ## SYNOPSIS _git am_ [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--no-verify] [--[no-]3way] [--interactive] [--committer-date-is-author-date] [--ignore-date] [--ignore-space-change | --ignore-whitespace] [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>] [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet] [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>] [--quoted-cr=<action>] [--empty=(stop|drop|keep)] [(<mbox> | <Maildir>)...] _git am_ (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty) ## DESCRIPTION Splits mail messages in a mailbox into commit log messages, authorship information, and patches, and applies them to the current branch. You could think of it as a reverse operation of git-format-patch(1) run on a branch with a straight history without merges. ## OPTIONS (<mbox>|<Maildir>)... The list of mailbox files to read patches from. If you do not supply this argument, the command reads from the standard input. If you supply directories, they will be treated as Maildirs. -s, --signoff Add a **Signed-off-by** trailer to the commit message, using the committer identity of yourself. See the signoff option in git-commit(1) for more information. -k, --keep Pass **-k** flag to _git mailinfo_ (see git-mailinfo(1)). --keep-non-patch Pass **-b** flag to _git mailinfo_ (see git-mailinfo(1)). --[no-]keep-cr With **--keep-cr** , call _git mailsplit_ (see git-mailsplit(1)) with the same option, to prevent it from stripping CR at the end of lines. **am.keepcr** configuration variable can be used to specify the default behaviour. **--no-keep-cr** is useful to override **am.keepcr**. -c, --scissors Remove everything in body before a scissors line (see git-mailinfo(1)). Can be activated by default using the **mailinfo.scissors** configuration variable. --no-scissors Ignore scissors lines (see git-mailinfo(1)). --quoted-cr=<action> This flag will be passed down to _git mailinfo_ (see git-mailinfo(1)). --empty=(drop|keep|stop) How to handle an e-mail message lacking a patch: **drop** The e-mail message will be skipped. **keep** An empty commit will be created, with the contents of the e-mail message as its log. **stop** The command will fail, stopping in the middle of the current **am** session. This is the default behavior. -m, --message-id Pass the **-m** flag to _git mailinfo_ (see git-mailinfo(1)), so that the Message-ID header is added to the commit message. The **am.messageid** configuration variable can be used to specify the default behaviour. --no-message-id Do not add the Message-ID header to the commit message. **no-message-id** is useful to override **am.messageid**. -q, --quiet Be quiet. Only print error messages. -u, --utf8 Pass **-u** flag to _git mailinfo_ (see git-mailinfo(1)). The proposed commit log message taken from the e-mail is re-coded into UTF-8 encoding (configuration variable **i18n.commitEncoding** can be used to specify the project’s preferred encoding if it is not UTF-8). This was optional in prior versions of git, but now it is the default. You can use **--no-utf8** to override this. --no-utf8 Pass **-n** flag to _git mailinfo_ (see git-mailinfo(1)). -3, --3way, --no-3way When the patch does not apply cleanly, fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally. **--no-3way** can be used to override am.threeWay configuration variable. For more information, see am.threeWay in git-config(1). **--rerere-autoupdate** , **--no-rerere-autoupdate** After the rerere mechanism reuses a recorded resolution on the current conflict to update the files in the working tree, allow it to also update the index with the result of resolution. **--no-rerere-autoupdate** is a good way to double-check what **rerere** did and catch potential mismerges, before committing the result to the index with a separate **git** **add**. --ignore-space-change, --ignore-whitespace, --whitespace=<action>, -C<n>, -p<n>, --directory=<dir>, --exclude=<path>, --include=<path>, --reject These flags are passed to the _git apply_ (see git-apply(1)) program that applies the patch. Valid <action> for the **--whitespace** option are: **nowarn** , **warn** , **fix** , **error** , and **error-all**. --patch-format By default the command will try to detect the patch format automatically. This option allows the user to bypass the automatic detection and specify the patch format that the patch(es) should be interpreted as. Valid formats are mbox, mboxrd, stgit, stgit-series, and hg. -i, --interactive Run interactively. -n, --no-verify By default, the pre-applypatch and applypatch-msg hooks are run. When any of **--no-verify** or **-n** is given, these are bypassed. See also githooks(5). --committer-date-is-author-date By default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the committer date by using the same value as the author date. --ignore-date By default the command records the date from the e-mail message as the commit author date, and uses the time of commit creation as the committer date. This allows the user to lie about the author date by using the same value as the committer date. --skip Skip the current patch. This is only meaningful when restarting an aborted patch. -S[<keyid>], --gpg-sign[=<keyid>], --no-gpg-sign GPG-sign commits. The **keyid** argument is optional and defaults to the committer identity; if specified, it must be stuck to the option without a space. **--no-gpg-sign** is useful to countermand both **commit.gpgSign** configuration variable, and earlier **--gpg-sign**. --continue, -r, --resolved After a patch failure (e.g. attempting to apply conflicting patch), the user has applied it by hand and the index file stores the result of the application. Make a commit using the authorship and commit log extracted from the e-mail message and the current index file, and continue. --resolvemsg=<msg> When a patch failure occurs, <msg> will be printed to the screen before exiting. This overrides the standard message informing you to use **--continue** or **--skip** to handle the failure. This is solely for internal use between _git rebase_ and _git am_. --abort Restore the original branch and abort the patching operation. Revert the contents of files involved in the am operation to their pre-am state. --quit Abort the patching operation but keep HEAD and the index untouched. --retry Try to apply the last conflicting patch again. This is generally only useful for passing extra options to the retry attempt (e.g., **--3way**), since otherwise you’ll just see the same failure again. --show-current-patch[=(diff|raw)] Show the message at which **git am** has stopped due to conflicts. If **raw** is specified, show the raw contents of the e-mail message; if **diff** , show the diff portion only. Defaults to **raw**. --allow-empty After a patch failure on an input e-mail message lacking a patch, create an empty commit with the contents of the e-mail message as its log message. ## DISCUSSION The commit author name is taken from the "From: " line of the message, and commit author date is taken from the "Date: " line of the message. The "Subject: " line is used as the title of the commit, after stripping common prefix "[PATCH <anything>]". The "Subject: " line is supposed to concisely describe what the commit is about in one line of text. "From: ", "Date: ", and "Subject: " lines starting the body override the respective commit author name and title values taken from the headers. The commit message is formed by the title taken from the "Subject: ", a blank line and the body of the message up to where the patch begins. Excess whitespace at the end of each line is automatically stripped. The patch is expected to be inline, directly following the message. Any line that is of the form: • three-dashes and end-of-line, or • a line that begins with "diff -", or • a line that begins with "Index: " is taken as the beginning of a patch, and the commit log message is terminated before the first occurrence of such a line. When initially invoking **git am** , you give it the names of the mailboxes to process. Upon seeing the first patch that does not apply, it aborts in the middle. You can recover from this in one of two ways: 1. skip the current patch by re-running the command with the **--skip** option. 2. hand resolve the conflict in the working directory, and update the index file to bring it into a state that the patch should have produced. Then run the command with the **--continue** option. The command refuses to process new mailboxes until the current operation is finished, so if you decide to start over from scratch, run **git am --abort** before running the command with mailbox names. Before any patches are applied, ORIG_HEAD is set to the tip of the current branch. This is useful if you have problems with multiple commits, like running _git am_ on the wrong branch or an error in the commits that is more easily fixed by changing the mailbox (e.g. errors in the "From:" lines). ## HOOKS This command can run **applypatch-msg** , **pre-applypatch** , and **post-applypatch** hooks. See githooks(5) for more information. ## CONFIGURATION Everything below this line in this section is selectively included from the git-config(1) documentation. The content is the same as what’s found there: am.keepcr If true, git-am will call git-mailsplit for patches in mbox format with parameter **--keep-cr**. In this case git-mailsplit will not remove **\r** from lines ending with **\r\n**. Can be overridden by giving **--no-keep-cr** from the command line. See git-am(1), git-mailsplit(1). am.threeWay By default, **git am** will fail if the patch does not apply cleanly. When set to true, this setting tells **git am** to fall back on 3-way merge if the patch records the identity of blobs it is supposed to apply to and we have those blobs available locally (equivalent to giving the **--3way** option from the command line). Defaults to **false**. See git-am(1). ## GIT Part of the git(1) suite * * *
# gencat ## PROLOG This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. ## NAME gencat — generate a formatted message catalog ## SYNOPSIS gencat _catfile msgfile_... ## DESCRIPTION The _gencat_ utility shall merge the message text source file _msgfile_ into a formatted message catalog _catfile_. The file _catfile_ shall be created if it does not already exist. If _catfile_ does exist, its messages shall be included in the new _catfile_. If set and message numbers collide, the new message text defined in _msgfile_ shall replace the old message text currently contained in _catfile_. ## OPTIONS None. ## OPERANDS The following operands shall be supported: _catfile_ A pathname of the formatted message catalog. If **'-'** is specified, standard output shall be used. The format of the message catalog produced is unspecified. _msgfile_ A pathname of a message text source file. If **'-'** is specified for an instance of _msgfile_ , standard input shall be used. The format of message text source files is defined in the EXTENDED DESCRIPTION section. ## STDIN The standard input shall not be used unless a _msgfile_ operand is specified as **'-'**. ## INPUT FILES The input files shall be text files. ## ENVIRONMENT VARIABLES The following environment variables shall affect the execution of _gencat_ : _LANG_ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1‐2017, _Section 8.2_ , _Internationalization Variables_ for the precedence of internationalization variables used to determine the values of locale categories.) _LC_ALL_ If set to a non-empty string value, override the values of all the other internationalization variables. _LC_CTYPE_ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files). _LC_MESSAGES_ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. _NLSPATH_ Determine the location of message catalogs for the processing of _LC_MESSAGES_. ## ASYNCHRONOUS EVENTS Default. ## STDOUT The standard output shall not be used unless the _catfile_ operand is specified as **'-'**. ## STDERR The standard error shall be used only for diagnostic messages. ## OUTPUT FILES None. ## EXTENDED DESCRIPTION The content of a message text file shall be in the format defined as follows. Note that the fields of a message text source line are separated by a single <blank> character. Any other <blank> characters are considered to be part of the subsequent field. **$set** _n comment_ This line specifies the set identifier of the following messages until the next **$set** or end-of-file appears. The _n_ denotes the set identifier, which is defined as a number in the range [1, {NL_SETMAX}] (see the _< limits.h>_ header defined in the Base Definitions volume of POSIX.1‐2017). The application shall ensure that set identifiers are presented in ascending order within a single source file, but need not be contiguous. Any string following the set identifier shall be treated as a comment. If no **$set** directive is specified in a message text source file, all messages shall be located in an implementation-defined default message set NL_SETD (see the _< nl_types.h>_ header defined in the Base Definitions volume of POSIX.1‐2017). **$delset** _n comment_ This line deletes message set _n_ from an existing message catalog. The _n_ denotes the set number [1, {NL_SETMAX}]. Any string following the set number shall be treated as a comment. **$**_comment_ A line beginning with **'$'** followed by a <blank> shall be treated as a comment. _m message-text_ The _m_ denotes the message identifier, which is defined as a number in the range [1, {NL_MSGMAX}] (see the _< limits.h>_ header). The _message-text_ shall be stored in the message catalog with the set identifier specified by the last **$set** directive, and with message identifier _m_. If the _message-text_ is empty, and a <blank> field separator is present, an empty string shall be stored in the message catalog. If a message source line has a message number, but neither a field separator nor _message-text_ , the existing message with that number (if any) shall be deleted from the catalog. The application shall ensure that message identifiers are in ascending order within a single set, but need not be contiguous. The application shall ensure that the length of _message-_ _text_ is in the range [0, {NL_TEXTMAX}] (see the _< limits.h>_ header). **$quote** _n_ This line specifies an optional quote character _c_ , which can be used to surround _message-text_ so that trailing <space> characters or null (empty) messages are visible in a message source line. By default, or if an empty **$quote** directive is supplied, no quoting of _message-text_ shall be recognized. Empty lines in a message text source file shall be ignored. The effects of lines starting with any character other than those defined above are implementation-defined. Text strings can contain the special characters and escape sequences defined in the following table: ┌───────────────────┬────────┬──────────┐ │ **Description** │ **Symbol** │ **Sequence** │ ├───────────────────┼────────┼──────────┤ │ <newline> │ NL(LF) │ \n │ │ Horizontal-tab │ HT │ \t │ │ <vertical-tab> │ VT │ \v │ │ <backspace> │ BS │ \b │ │ <carriage-return> │ CR │ \r │ │ <form-feed> │ FF │ \f │ │ Backslash │ \ │ \\ │ │ Bit pattern │ ddd │ \ddd │ └───────────────────┴────────┴──────────┘ The escape sequence **"\ddd"** consists of <backslash> followed by one, two, or three octal digits, which shall be taken to specify the value of the desired character. If the character following a <backslash> is not one of those specified, the <backslash> shall be ignored. A <backslash> followed by a <newline> is also used to continue a string on the following line. Thus, the following two lines describe a single message string: 1 This line continues \ to the next line which shall be equivalent to: 1 This line continues to the next line ## EXIT STATUS The following exit values shall be returned: 0 Successful completion. >0 An error occurred. ## CONSEQUENCES OF ERRORS Default. _The following sections are informative._ ## APPLICATION USAGE Message catalogs produced by _gencat_ are binary encoded, meaning that their portability cannot be guaranteed between different types of machine. Thus, just as C programs need to be recompiled for each type of machine, so message catalogs must be recreated via _gencat_. ## EXAMPLES None. ## RATIONALE None. ## FUTURE DIRECTIONS None. * * *
# pmie_dump_stats ## NAME **pmie_dump_stats** - dump the contents of pmie stats files ## SYNOPSIS **$PCP_BINADM_DIR/pmie_dump_stats** _file_ [...] ## DESCRIPTION Each pmie(1) process maintains a file of state and statistics in binary files in the **$PCP_TMP_DIR/pmie** directory, named with the process' PID. These files are used by the **pmcd** PMDA to instantiate the **pmcd.pmie** performance metrics. **pmie_dump_stats** is a stand alone utility that dumps the contents of these files in a terse, but script-friendly format. It is designed for use in the **pmiectl**(1) script. * * *
# lttng-rotate ## NAME lttng-rotate - Archive a tracing session's current trace chunk ## SYNOPSIS **lttng**[_GENERAL OPTIONS_] **rotate**[**--no-wait**] [_SESSION_] ## DESCRIPTION The **lttng rotate** command archives the current trace chunk of the current tracing session, or of the tracing session named _SESSION_ if provided, to the file system. This action is called a tracing session _rotation_. Once a trace chunk is archived, LTTng does not manage it anymore: you can read it, modify it, move it, or remove it. An archived trace chunk is a collection of metadata and data stream files which form a self-contained trace. The _current trace chunk_ of a given tracing session includes: • The stream files already written to the file system, and which are not part of a previously archived trace chunk, since the most recent event amongst: • The first time the tracing session was started with lttng-start(1). • The last rotation, either an immediate one with **lttng** **rotate** , or an automatic one from a rotation schedule previously set with lttng-enable-rotation(1). • The content of all the non-flushed sub-buffers of the tracing session’s channels. You can use **lttng rotate** either at any time when the tracing session is active (see lttng-start(1)), or a single time once the tracing session becomes inactive (see lttng-stop(1)). By default, the **lttng rotate** command ensures that the rotation is done before printing the archived trace chunk’s path and returning to the prompt. The printed path is absolute when the tracing session was created in normal mode and relative to the relay daemon’s output directory (see the **--output** option in lttng-relayd(8)) when it was created in network streaming mode (see lttng-create(1)). With the **--no-wait** option, the command finishes immediately, hence a rotation might not be completed when the command is done. In this case, there is no easy way to know when the current trace chunk is archived, and the command does not print the archived trace chunk’s path. Because a rotation causes the tracing session’s current sub-buffers to be flushed, archived trace chunks are never redundant, that is, they do not overlap over time like snapshots can (see lttng-snapshot(1)). Also, a rotation does not directly cause discarded event records or packets. See _LIMITATIONS_ for important limitations regarding this command. **Trace chunk archive naming** A trace chunk archive is a subdirectory of a tracing session’s output directory (see the **--output** option in lttng-create(1)) which contains, through tracing domain and possibly UID/PID subdirectories, metadata and data stream files. A trace chunk archive is, at the same time: • A self-contained LTTng trace. • A member of a set of trace chunk archives which form the complete trace of a tracing session. In other words, an LTTng trace reader can read both the tracing session output directory (all the trace chunk archives), or a single trace chunk archive. When a tracing session rotation occurs, the created trace chunk archive is named: _BEGIN_ -_END_ -_ID_ _BEGIN_ Date and time of the beginning of the trace chunk archive with the ISO 8601-compatible **YYYYmmddTHHMMSS±HHMM** form, where **YYYYmmdd** is the date and **HHMMSS±HHMM** is the time with the time zone offset from UTC. Example: **20171119T152407-0500** _END_ Date and time of the end of the trace chunk archive with the ISO 8601-compatible **YYYYmmddTHHMMSS±HHMM** form, where **YYYYmmdd** is the date and **HHMMSS±HHMM** is the time with the time zone offset from UTC. Example: **20180118T152407+0930** _ID_ Unique numeric identifier of the trace chunk within its tracing session. Trace chunk archive name example: **20171119T152407-0500-20171119T151422-0500-3** ## OPTIONS General options are described in lttng(1). **-n** , **--no-wait** Do not ensure that the rotation is done before returning to the prompt. **Program information** **-h** , **--help** Show command help. This option, like lttng-help(1), attempts to launch **/usr/bin/man** to view the command’s man page. The path to the man pager can be overridden by the **LTTNG_MAN_BIN_PATH** environment variable. **--list-options** List available command options. ## LIMITATIONS The **lttng rotate** command only works when: • The tracing session is created in normal mode or in network streaming mode (see lttng-create(1)). • No channel was created with a configured trace file count or size limit (see the **--tracefile-size** and **--tracefile-count** options in lttng-enable-channel(1)). • No immediate rotation (**lttng rotate**) is currently happening. ## ENVIRONMENT VARIABLES **LTTNG_ABORT_ON_ERROR** Set to 1 to abort the process after the first error is encountered. **LTTNG_HOME** Overrides the **$HOME** environment variable. Useful when the user running the commands has a non-writable home directory. **LTTNG_MAN_BIN_PATH** Absolute path to the man pager to use for viewing help information about LTTng commands (using lttng-help(1) or **lttng** **COMMAND --help**). **LTTNG_SESSION_CONFIG_XSD_PATH** Path in which the **session.xsd** session configuration XML schema may be found. **LTTNG_SESSIOND_PATH** Full session daemon binary path. The **--sessiond-path** option has precedence over this environment variable. Note that the lttng-create(1) command can spawn an LTTng session daemon automatically if none is running. See lttng-sessiond(8) for the environment variables influencing the execution of the session daemon. ## FILES **$LTTNG_HOME/.lttngrc** User LTTng runtime configuration. This is where the per-user current tracing session is stored between executions of lttng(1). The current tracing session can be set with lttng-set-session(1). See lttng-create(1) for more information about tracing sessions. **$LTTNG_HOME/lttng-traces** Default output directory of LTTng traces. This can be overridden with the **--output** option of the lttng-create(1) command. **$LTTNG_HOME/.lttng** User LTTng runtime and configuration directory. **$LTTNG_HOME/.lttng/sessions** Default location of saved user tracing sessions (see lttng-save(1) and lttng-load(1)). **/usr/local/etc/lttng/sessions** System-wide location of saved tracing sessions (see lttng-save(1) and lttng-load(1)). **Note** **$LTTNG_HOME** defaults to **$HOME** when not explicitly set. ## EXIT STATUS **0** Success **1** Command error **2** Undefined command **3** Fatal error **4** Command warning (something went wrong during the command) ## BUGS If you encounter any issue or usability problem, please report it on the LTTng bug tracker <https://bugs.lttng.org/projects/lttng- tools>. ## RESOURCES • LTTng project website <https://lttng.org> • LTTng documentation <https://lttng.org/docs> • Git repositories <http://git.lttng.org> • GitHub organization <http://github.com/lttng> • Continuous integration <http://ci.lttng.org/> • Mailing list <http://lists.lttng.org> for support and development: **[email protected]** • IRC channel <irc://irc.oftc.net/lttng>: **#lttng** on **irc.oftc.net** ## THANKS Special thanks to Michel Dagenais and the DORSAL laboratory <http://www.dorsal.polymtl.ca/> at École Polytechnique de Montréal for the LTTng journey. Also thanks to the Ericsson teams working on tracing which helped us greatly with detailed bug reports and unusual test cases. * * *
# grog ## Name grog - “groff guess”—infer the _groff_ command a document requires ## Synopsis **grog**[_groff-option_ ...] [**--**] [_file_ ...] **grog -h** **grog --help** **grog -v** **grog --version** ## Description _grog_ reads its input and guesses which _groff_(1) options are needed to render it. If no operands are given, or if _file_ is “**-** ”, _grog_ reads the standard input stream. The corresponding _groff_ command is normally written to the standard output stream. ## Options **-h** and **--help** display a usage message, whereas **-v** and **--version** display version information; all exit afterward. All other specified short options (that is, arguments beginning with a minus sign “**-** ” followed by a letter) are interpreted as _groff_ options or option clusters with or without an option argument. Such options are included in the constructed _groff_ command line. ## Details _grog_ reads each _file_ operand, pattern-matching strings that are statistically likely to be characteristic of _roff_(7) documents. It tries to guess which of the following _groff_ options are required to correctly render the input: **-e** , **-g** , **-G** , **-j** , **-p** , **-R** , **-t** (preprocessors); and **-man** , **-mdoc** , **-mdoc-old** , **-me** , **-mm** , **-mom** , and **-ms**(macro packages). The inferred _groff_ command including these options and any _file_ parameters is written to the standard output stream. It is possible to specify arbitrary _groff_ options on the command line. These are included in the inferred command without change. Choices of _groff_ options include **-C** to enable AT&T _troff_ compatibility mode and **-T** to select a non-default output device. If the input is not encoded in ISO 646:1991 IRV (US-ASCII) or ISO Latin-1 (8859-1), we advise specifying a _groff_ option to run the _preconv_(1;) see the **-D** , **-k** , and **-K** options of _groff_(1). For UTF-8 input, **-k** is a good choice. _groff_ may issue diagnostic messages when an inappropriate **-m** option, or multiple conflicting ones, are specified. Consequently, it is best to specify no **-m** options to _grog_ unless it cannot correctly infer all of the **-m** arguments a document requires. A _roff_ document can also be written without recourse to any macro package. In such cases, _grog_ will infer a _groff_ command without an **-m** option. **Limitations** _grog_ presumes that the input does not change the escape, control, or no-break control characters. _grog_ does not parse _roff_ input line continuation or control structures (brace escape sequences and the “**if** ”, “**ie** ”, and “**el** ” requests) nor _groff_ 's “**while** ”. Thus the input .if \ t .NH 1 .if n .SH Introduction will conceal the use of the _ms_ macros **NH** and **SH** from _grog_. Such constructions are regarded by _grog_ 's implementors as insufficiently common to cause many inference problems. Preprocessors can be even stricter when matching macro calls that bracket the regions of an input file they replace. _pic_ , for example, requires **PS** , **PE** , and **PF** calls to immediately follow the default control character at the beginning of a line. Detection of the **-s** option (the _soelim_(1) preprocessor) is tricky; to correctly infer its necessity would require _grog_ to recursively open all files given as arguments to the **.so** request under the same conditions that _soelim_ itself does so; see its man page. Recall that _soelim_ is necessary only if sourced files need to be preprocessed. Therefore, as a workaround, you may want to run the input through _soelim_ manually, piping it to _grog_ , and compare the output to running _grog_ on the input directly. If the “ _soelim_ ”ed input causes _grog_ to infer additional preprocessor options, then **-s** is likely necessary. $ **printf ".TS\nl.\nI'm a table.\n.TE\n" > 3.roff** $ **printf ".so 3.roff\n" > 2.roff** $ **printf ".XP\n.so 2.roff\n" > 1.roff** $ **grog 1.roff** groff -ms 1.roff $ **soelim 1.roff | grog** groff -t -ms - In the foregoing example, we see that this procedure enabled _grog_ to detect _tbl_(1) macros, so we would add **-s** as well as the detected **-t** option to a revised _grog_ or _groff_ command. $ **grog -st 1.roff** groff -st -ms 1.roff ## Exit status _grog_ exits with status **1** if a macro package appears to be in use by the input document, but _grog_ was unable to infer which one, or **2** if there were problems handling an option or operand. It otherwise exits with status **0**. Inferring no preprocessors or macro packages is not an error condition; a valid _roff_ document need not use either. Even plain text is valid input, if one is mindful of the syntax of the control and escape characters. ## Examples Running **grog /usr/local/share/doc/groff-1.23.0/meintro.me** at the command line results in groff -me /usr/local/share/doc/groff-1.23.0/meintro.me because _grog_ recognizes that the file _meintro.me_ is written using macros from the _me_ package. The command **grog /usr/local/share/doc/groff-1.23.0/pic.ms** outputs groff -e -p -t -ms /usr/local/share/doc/groff-1.23.0/pic.ms on the other hand. Besides discerning the _ms_ macro package, _grog_ recognizes that the file _pic.ms_ additionally needs the combination of **-t** for _tbl_ , **-e** for _eqn_ , and **-p** for _pic_. Consider a file _doc/grnexampl.me_ , which uses the _grn_ preprocessor to include a _gremlin_(1) picture file in an _me_ document. Let's say we want to suppress color output, produce a DVI file, and get backtraces for any errors that _troff_ encounters. The command **grog -bc -Idoc -Tdvi doc/grnexmpl.me** is processed by _grog_ into groff -bc -Idoc -Tdvi -e -g -me doc/grnexmpl.me where we can see that _grog_ has inferred the _me_ macro package along with the _eqn_ and _grn_ preprocessors. (The input file is located in _/usr/local/share/doc/groff-1.23.0_ if you'd like to try this example yourself.) ## Authors _grog_ was originally written in Bourne shell by James Clark. The current implementation in Perl was written by Bernd Warken ⟨[email protected]⟩ and heavily revised by G. Branden Robinson ⟨[email protected]⟩. ## See also _groff_(1) * * *
# setfacl ## NAME setfacl - set file access control lists ## SYNOPSIS **setfacl**[-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ... **setfacl** --restore={file|-} ## DESCRIPTION This utility sets Access Control Lists (ACLs) of files and directories. On the command line, a sequence of commands is followed by a sequence of files (which in turn can be followed by another sequence of commands, ...). The _-m_ and _-x_ options expect an ACL on the command line. Multiple ACL entries are separated by comma characters (`,'). The _-M_ and _-X_ options read an ACL from a file or from standard input. The ACL entry format is described in Section ACL ENTRIES. The _--set_ and _--set-file_ options set the ACL of a file or a directory. The previous ACL is replaced. ACL entries for this operation must include permissions. The _-m (--modify)_ and _-M (--modify-file)_ options modify the ACL of a file or directory. ACL entries for this operation must include permissions. The _-x (--remove)_ and _-X (--remove-file)_ options remove ACL entries. It is not an error to remove an entry which does not exist. Only ACL entries without the _perms_ field are accepted as parameters, unless POSIXLY_CORRECT is defined. When reading from files using the _-M_ and _-X_ options, setfacl accepts the output getfacl produces. There is at most one ACL entry per line. After a Pound sign (`#'), everything up to the end of the line is treated as a comment. If setfacl is used on a file system which does not support ACLs, setfacl operates on the file mode permission bits. If the ACL does not fit completely in the permission bits, setfacl modifies the file mode permission bits to reflect the ACL as closely as possible, writes an error message to standard error, and returns with an exit status greater than 0. **PERMISSIONS** The file owner and processes capable of CAP_FOWNER are granted the right to modify ACLs of a file. This is analogous to the permissions required for accessing the file mode. (On current Linux systems, root is the only user with the CAP_FOWNER capability.) ## OPTIONS _-b, --remove-all_ Remove all extended ACL entries. The base ACL entries of the owner, group and others are retained. _-k, --remove-default_ Remove the Default ACL. If no Default ACL exists, no warnings are issued. _-n, --no-mask_ Do not recalculate the effective rights mask. The default behavior of setfacl is to recalculate the ACL mask entry, unless a mask entry was explicitly given. The mask entry is set to the union of all permissions of the owning group, and all named user and group entries. (These are exactly the entries affected by the mask entry). _--mask_ Do recalculate the effective rights mask, even if an ACL mask entry was explicitly given. (See the _-n_ option.) _-d, --default_ All operations apply to the Default ACL. Regular ACL entries in the input set are promoted to Default ACL entries. Default ACL entries in the input set are discarded. (A warning is issued if that happens). _--restore={file|-}_ Restore a permission backup created by `getfacl -R' or similar. All permissions of a complete directory subtree are restored using this mechanism. If the input contains owner comments or group comments, setfacl attempts to restore the owner and owning group. If the input contains flags comments (which define the setuid, setgid, and sticky bits), setfacl sets those three bits accordingly; otherwise, it clears them. This option cannot be mixed with other options except `--test'. If the file specified is '**-** ', then it will be read from standard input. _--test_ Test mode. Instead of changing the ACLs of any files, the resulting ACLs are listed. _-R, --recursive_ Apply operations to all files and directories recursively. This option cannot be mixed with `--restore'. _-L, --logical_ Logical walk, follow symbolic links to directories. The default behavior is to follow symbolic link arguments, and skip symbolic links encountered in subdirectories. Only effective in combination with -R. This option cannot be mixed with `--restore'. _-P, --physical_ Physical walk, do not follow symbolic links to directories. This also skips symbolic link arguments. Only effective in combination with -R. This option cannot be mixed with `--restore'. _-v, --version_ Print the version of setfacl and exit. _-h, --help_ Print help explaining the command line options. _--_ End of command line options. All remaining parameters are interpreted as file names, even if they start with a dash. _-_ If the file name parameter is a single dash, setfacl reads a list of files from standard input. **ACL ENTRIES** The setfacl utility recognizes the following ACL entry formats (blanks inserted for clarity): [d[efault]:] [u[ser]:]_uid_ [:_perms_] Permissions of a named user. Permissions of the file owner if _uid_ is empty. [d[efault]:] g[roup]:_gid_ [:_perms_] Permissions of a named group. Permissions of the owning group if _gid_ is empty. [d[efault]:] m[ask][:] [:_perms_] Effective rights mask [d[efault]:] o[ther][:] [:_perms_] Permissions of others. Whitespace between delimiter characters and non-delimiter characters is ignored. Proper ACL entries including permissions are used in modify and set operations. (options _-m_ , _-M_ , _--set_ and _--set-file_). Entries without the _perms_ field are used for _deletion_ of entries (options _-x_ and _-X_). For _uid_ and _gid_ you can specify either a name or a number. Character literals may be specified with a backslash followed by the 3-digit octal digits corresponding to the ASCII code for the character (e.g., _\101_ for 'A'). If the name contains a literal backslash followed by 3 digits, the backslash must be escaped (i.e., _\\_). The _perms_ field is a combination of characters that indicate the read _(r)_ , write _(w)_ , execute _(x)_ permissions. Dash characters in the _perms_ field _(-)_ are ignored. The character _X_ stands for the execute permission if the file is a directory or already has execute permission for some user. Alternatively, the _perms_ field can define the permissions numerically, as a bit-wise combination of read _(4)_ , write _(2)_ , and execute _(1)_. Zero _perms_ fields or _perms_ fields that only consist of dashes indicate no permissions. **AUTOMATICALLY CREATED ENTRIES** Initially, files and directories contain only the three base ACL entries for the owner, the group, and others. There are some rules that need to be satisfied in order for an ACL to be valid: * The three base entries cannot be removed. There must be exactly one entry of each of these base entry types. * Whenever an ACL contains named user entries or named group objects, it must also contain an effective rights mask. * Whenever an ACL contains any Default ACL entries, the three Default ACL base entries (default owner, default group, and default others) must also exist. * Whenever a Default ACL contains named user entries or named group objects, it must also contain a default effective rights mask. To help the user ensure these rules, setfacl creates entries from existing entries under the following conditions: * If an ACL contains named user or named group entries, and no mask entry exists, a mask entry containing the same permissions as the group entry is created. Unless the _-n_ option is given, the permissions of the mask entry are further adjusted to include the union of all permissions affected by the mask entry. (See the _-n_ option description). * If a Default ACL entry is created, and the Default ACL contains no owner, owning group, or others entry, a copy of the ACL owner, owning group, or others entry is added to the Default ACL. * If a Default ACL contains named user entries or named group entries, and no mask entry exists, a mask entry containing the same permissions as the default Default ACL's group entry is added. Unless the _-n_ option is given, the permissions of the mask entry are further adjusted to include the union of all permissions affected by the mask entry. (See the _-n_ option description). ## EXAMPLES Granting an additional user read access setfacl -m u:lisa:r file Revoking write access from all groups and all named users (using the effective rights mask) setfacl -m m::rx file Removing a named group entry from a file's ACL setfacl -x g:staff file Copying the ACL of one file to another getfacl file1 | setfacl --set-file=- file2 Copying the access ACL into the Default ACL getfacl --access dir | setfacl -d -M- dir ## CONFORMANCE TO POSIX 1003.1e DRAFT STANDARD 17 If the environment variable POSIXLY_CORRECT is defined, the default behavior of setfacl changes as follows: All non-standard options are disabled. The ``default:'' prefix is disabled. The _-x_ and _-X_ options also accept permission fields (and ignore them). * * *
# yum-filter-data ## NAME yum filter data plugin ## SYNOPSIS **yum**[options] [command] [package ...] ## DESCRIPTION This plugin extends **yum** with some options, currently just for "update" and "list update" type commands, to allow filters to be placed on which packages should be used based on the data in those packages. Note that due to some of the data being unknown, and thus could possibly match, all unknown data is treated as a match. ## GENERAL OPTIONS These are the options added to yum that are available in the "list updates", "info updates", "check-update" and "update" commands. They are: **--filter-vendors** This option includes packages which have a vendor which matches one of the passed vendor wildcard strings, or is unknown. Note that vendors can have spaces in their value, so "," is the only way to specify multiple vendors as one option argument. **--filter-rpm-groups** This option includes packages which have a group which matches one of the passed rpm group wildcard strings, or is unknown. Note that rpm groups can have spaces in their value, so "," is the only way to specify multiple rpm groups as one option argument. **--filter-packagers** This option includes packages which have a packager which matches one of the passed packager wildcard strings, or is unknown. Note that vendors can have spaces in their value, so "," is the only way to specify multiple packagers as one option argument. **--filter-licenses** This option includes packages which have a license which matches one of the passed license wildcard strings, or is unknown. Note that licenses can have spaces in their value, so "," is the only way to specify multiple licenses as one option argument. **--filter-arches** This option includes packages which have a arch which matches one of the passed arch wildcard strings, or is unknown. **--filter-committers** This option includes packages which have a committer which matches one of the passed committer wildcard strings, or is unknown. Note that committers can have spaces in their value, so "," is the only way to specify multiple committers as one option argument. Also, committer values are so loosely formed that they could contain commas too, it is recommended to not do that but you can work around it by using "?". **--filter-buildhosts** This option includes packages which have a buildhost which matches one of the passed buildhost wildcard strings, or is unknown. **--filter-urls** This option includes packages which have a url which matches one of the passed url wildcard strings, or is unknown. **--filter-package-sizes** This option includes packages which have a packagesize which is within one of the passed packagesize ranges, or is unknown. **--filter-archive-sizes** This option includes packages which have a archivesize which is within one of the passed archivesize ranges, or is unknown. **--filter-installed-sizes** This option includes packages which have a installedsize which is within one of the passed installedsize ranges, or is unknown. **--filter-groups** This option includes packages which are in a yum group which matches one of the passed yum group id strings, or is unknown. Note that yum groups can have spaces in their value, so "," is the only way to specify multiple yum groups as one option argument. ## EXAMPLES To list all updates that are 1 MB or less use: yum --filter-package-sizes=-1m check-update To apply updates that Dan Walsh has committed use: yum --filter-committers='Dan Walsh *' update To list updates for a specific group use: yum --filter-rpm-groups='App*/Sys*' list updates To apply updates to a specific set of groups use: yum --filter-rpm-groups='App*/System,Devel*/Lib*,System Environment/Base' update To list updates for a set of yum groups use: yum --filter-groups='PostgreSQL Database,Web Server' list updates To apply updates to a specific set of yum groups use: yum --filter-groups='KDE,Core,Printing Support' update ## BUGS Currently yum can't filter packages in all of the commands, so for instance "yum list 'yum*'" doesn't get the results filtered. Apart from that there are no bugs, but should you find any, you should first consult the FAQ section on http://yum.baseurl.org/wiki/Faq and if unsuccessful in finding a resolution contact the mailing list: [email protected]. To file a bug use http://bugzilla.redhat.com for Fedora/RHEL/Centos related bugs and http://yum.baseurl.org/report for all other bugs. * * *