Sub topic 12
Equivalent Commands on Linux and macOS
This chapter assumes you have used ipconfig, ping, and tracert on Windows. It also assumes you know what an IP address, a default gateway, and a DNS server are, and that you can open a terminal. The goal is to map each Windows tool to its Linux and macOS counterpart. The chapter also covers the differences in options and defaults that cause confusion when you switch systems.
The Mapping at a Glance
The concepts are identical across systems: the same ICMP messages, the same TTL mechanism, the same layered method. What changes is the command name, the option letters, and some default behavior.
| Task | Windows | Linux | macOS |
|---|---|---|---|
| Show addresses | `ipconfig` | `ip addr show` | `ifconfig` |
| Show detail (MAC, DNS, DHCP) | `ipconfig /all` | `ip addr show`, `ip link show`, `resolvectl status` | `ifconfig`, `scutil --dns` |
| Show default gateway | `ipconfig` | `ip route show` | `netstat -rn` or `route -n get default` |
| Test reachability | `ping` | `ping` | `ping` |
| Trace the path | `tracert` | `traceroute` | `traceroute` |
| Flush DNS cache | `ipconfig /flushdns` | depends on resolver | `sudo dscacheutil -flushcache` |
ping keeps its name everywhere. tracert becomes traceroute. ipconfig has no single equivalent, because the information is spread across several commands.
Replacing ipconfig
Linux: the ip command
Modern Linux distributions use the ip command from the iproute2 package. It replaces the older ifconfig and route commands, which may not be installed.
ip addr show
ip route showip addr show lists each interface with its IPv4 and IPv6 addresses. The address appears with a prefix length, such as 192.168.1.25/24. The /24 is another way to write the subnet mask 255.255.255.0. Windows prints the mask in dotted form instead.
ip route show supplies the default gateway. Look for the line that begins with default:
ip route showA typical line reads default via 192.168.1.1 dev eth0. The address after via is the default gateway, and dev names the interface that reaches it.
The MAC address appears in ip link show, on the line starting with link/ether. Also, ip addr show lists it for each interface.
Linux: DNS servers and DHCP
Linux has no single place to read DNS servers. On many current distributions, systemd-resolved manages DNS, and resolvectl status lists the servers per interface. On other systems, the file /etc/resolv.conf lists them. On systemd-resolved systems that file often shows a local stub address such as 127.0.0.53. That address is the local resolver, not the upstream DNS server.
DHCP lease handling also depends on the tool that manages the network, such as NetworkManager or systemd-networkd. There is no universal counterpart to ipconfig /release and /renew. With NetworkManager you can reconnect an interface with nmcli. Check which network manager your system uses before you change a lease.
macOS: ifconfig and netstat
macOS still ships ifconfig. Running it with no options lists every interface. The IPv4 address appears on the inet line. The subnet mask appears as a hexadecimal value, for example netmask 0xffffff00, which equals 255.255.255.0. The MAC address appears on the ether line.
ifconfig
netstat -rnnetstat -rn prints the routing table without resolving names. The default row shows the gateway. For a single answer, use route -n get default, which prints the gateway and the interface.
To see DNS servers on macOS, run scutil --dns. The nameserver lines list the servers. Reading /etc/resolv.conf on macOS can mislead you, because the system resolver does not rely on it.
scutil --dnsLease and cache commands
The three Windows commands ipconfig /release, /renew, and /flushdns have no one-to-one replacement. On macOS you can flush the DNS cache with sudo dscacheutil -flushcache. Some macOS versions also need sudo killall -HUP mDNSResponder. On Linux, flushing depends on the resolver. With systemd-resolved, resolvectl flush-caches clears the cache.
ping on Linux and macOS
The command name and the idea are the same. Two differences matter in practice.
- On Linux and macOS,
pingruns until you press Ctrl+C. On Windows, it sends four requests and stops. - The option letters differ. Windows uses
-nfor the count. Linux and macOS use-c.
ping -c 10 8.8.8.8When you stop the command, or when the count finishes, ping prints a summary. It reports packets sent and received, the loss percentage, and the round-trip times as minimum, average, maximum, and a deviation figure. Linux labels the line rtt min/avg/max/mdev. macOS labels it round-trip min/avg/max/stddev. The numbers carry the same meaning as the Windows summary.
The output of each reply line also differs a little. Linux and macOS print icmp_seq, the sequence number of the request, and ttl, the remaining TTL of the reply, in lowercase. Gaps in icmp_seq show lost packets. Windows has no sequence number in its reply lines, so the Linux output makes loss easier to see as it happens.
The TTL values still hint at the operating system of the remote host. Many Linux and macOS hosts start at 64, and Windows hosts start at 128. The remaining value is what is left after the replies cross the path. Treat this as a rough hint, because administrators can change the starting value.
Common ping options
| Purpose | Windows | Linux | macOS |
|---|---|---|---|
| Number of requests | `-n 10` | `-c 10` | `-c 10` |
| Run until stopped | `-t` | default | default |
| Payload size | `-l 1472` | `-s 1472` | `-s 1472` |
| Set Don't Fragment | `-f` | `-M do` | `-D` |
| Interval between requests | not available | `-i 0.5` | `-i 0.5` |
The Windows example for probing the path MTU was ping -f -l 1472 8.8.8.8. The Linux equivalent follows.
ping -M do -s 1472 -c 4 8.8.8.8On macOS, use this form:
ping -D -s 1472 -c 4 8.8.8.8As on Windows, the payload of 1472 bytes plus 28 bytes of headers makes a 1500-byte packet. If an interface or router along the path has a smaller MTU, you receive an error that the packet needs fragmentation instead of a normal reply.
Short intervals below 0.2 seconds usually need root on Linux, which prevents ordinary users from flooding a network by accident.
traceroute on Linux and macOS
The command traceroute does the same job as tracert, but its default probes differ, and this changes what you see.
traceroute example.com
traceroute -n example.com
sudo traceroute -I example.com- By default,
traceroutesends UDP packets to high port numbers. Each probe has a TTL that increases by one, as described in the chapter on TTL. The routers reply with ICMP Time Exceeded, and the final host replies with ICMP Port Unreachable, which marks the end of the trace. - With
-I, it sends ICMP echo requests, as Windowstracertdoes. On Linux this typically requires root. - With
-n, it skips reverse DNS lookups. This is the same speedup that-dgives on Windows.
Each hop line shows three probes by default, so you see three times per hop. An asterisk means a probe got no reply within the timeout. The meaning is the same as in Windows output.
| Purpose | Windows | Linux and macOS |
|---|---|---|
| No name lookups | `-d` | `-n` |
| Maximum hops | `-h 20` | `-m 20` |
| ICMP probes | default | `-I` |
| Timeout per probe | `-w` (milliseconds) | `-w` (seconds) |
Notice the timeout unit. Windows -w takes milliseconds, and traceroute -w takes seconds. A value of -w 3 is fast on Linux but absurdly short on Windows.
Why the probe type matters
Because the default probe is UDP, a trace can behave differently from a Windows trace of the same destination. A firewall that blocks UDP to high ports, or one that blocks ICMP echo, can stop one kind of probe and pass the other. If a default traceroute stalls with asterisks, try sudo traceroute -I before you conclude that the path is broken. Likewise, if an ICMP trace fails, a UDP trace may get through. This is the same filtering issue covered in the chapter on when tests mislead.
Some Linux distributions do not install traceroute by default. Install it with your package manager, for example sudo apt install traceroute on Debian and Ubuntu. Another option is tracepath, which needs no root and also reports the path MTU.
Pathping Alternatives
Windows has pathping for per-hop loss statistics. Linux and macOS have no command of that name. The closest tool is mtr, which combines traceroute and ping in one live display. It is not installed by default, but you can add it with a package manager (apt install mtr or brew install mtr).
mtr -n -c 20 --report example.comThe --report option prints a summary after 20 cycles, and -n skips name lookups. The output shows loss and latency per hop.
A Layered Sequence on Linux
The layered method from the troubleshooting chapter works unchanged. Only the commands change.
ping -c 3 127.0.0.1
ip addr show
ip route show
ping -c 3 192.168.1.1
ping -c 3 8.8.8.8
ping -c 3 example.comReplace 192.168.1.1 with the gateway address from ip route show. The first failing step points to the failing layer, exactly as on Windows.
Common Errors When Switching Systems
- Typing
ping -n 10on Linux. Linux reads-nas "numeric output only" and then fails to parse10as a host name. Use-c. - Expecting ping to stop by itself. On Linux and macOS, a bare
pingnever ends until Ctrl+C. - Running
ifconfigon a minimal Linux install. The command may be missing. Useip addr show. - Trusting
/etc/resolv.conf. On systems with a local stub resolver, it shows the stub, not the real DNS servers. - Comparing UDP and ICMP traces. The two probe types may follow different filtering rules, so differences between results do not always mean a routing difference.
- Reading
-was the same unit. Windows uses milliseconds andtracerouteuses seconds.
Exercise
You are on a Linux machine and want to run the equivalent of the Windows command tracert -d -h 20 example.com, forcing ICMP echo probes so the trace behaves like the Windows one. Which command do you run, and why might it need extra privileges?
Show answer
Run sudo traceroute -n -m 20 -I example.com. The -n option replaces -d (no name lookups), -m 20 replaces -h 20 (maximum hops), and -I switches the probes from the default UDP to ICMP echo. Sending ICMP echo probes typically needs root on Linux, so the command is run with sudo.
Exercise
On a Linux machine, how do you find your default gateway and test whether a 1500-byte packet reaches 8.8.8.8 without fragmentation?
Show answer
Run ip route show and read the address after default via. Then run ping -M do -s 1472 -c 4 8.8.8.8. The 1472-byte payload plus 28 bytes of headers makes a 1500-byte packet, and -M do sets the Don't Fragment behavior. Replies mean the path passes 1500 bytes. A message that fragmentation is needed means a smaller MTU exists on the path.