Skip to content

OS-independent troubleshooting: one method, and the commands for Linux, Windows and macOS

Six steps that find a fault on any operating system, a bottom-up worked example of a site that won't load, and the same checks on Linux, Windows and macOS.

6 min read

OS-independent troubleshooting is a way of finding a fault that works the same on any operating system (OS), whether Windows, Linux or macOS: the steps stay fixed and only the commands change. Most problems that look like "the computer is broken" are one layer failing underneath everything above it, and the job is to find which layer before changing anything. To run the checks on your own machine, skip to Check yours on Linux and Windows.

The steps

  1. Get the exact symptom. The full error text, when it started, and what changed just before.
  2. Reproduce it. A fault you can trigger on demand is a fault you can test a fix against.
  3. Test from the bottom up. Power and hardware, then the connection, the address, the route, name resolution, the service, and the application last.
  4. Change one thing at a time. Test after each change, and undo it if it didn't help.
  5. Read the logs. The system usually wrote down what went wrong before anyone asked.
  6. Write down the cause and the fix. The second time it happens, that note is the fix.

Steps 3 and 4 do most of the work. Testing bottom up means each check rules out everything under it, so a passing test is as useful as a failing one. Changing several things at once means that when the problem goes away, nobody knows which change fixed it, or what the other changes broke.

Why bottom up

Every layer depends on the ones below it, the same stack covered in the Open Systems Interconnection (OSI) and TCP/IP models. A browser can't load a page if the name doesn't resolve, the name can't resolve if the resolver isn't reachable, and nothing is reachable without an address and a route.

So when a page won't load, check the browser last.

Check yours on Linux and Windows

The worked example is a website that won't load, checked bottom up, one command per layer. On Linux every step below passed, which is the point of showing it: this is what "working" looks like at each layer, to compare against when something isn't.

On Linux

Does the interface have an address?

bash
ifconfig
text
wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.40  netmask 255.255.255.0  broadcast 192.168.100.255

Only the first two lines of the Wi-Fi interface are shown. UP in the flags and an inet line with a private address mean this layer works. An interface without UP, or with no inet line, or with an address starting 169.254, stops the search here: that last one is an address a machine gives itself when no server handed it one.

Is there a route out, and through which gateway?

bash
route -n
text
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.1   0.0.0.0         UG    600    0        0 wlp0s20f3
192.168.100.0   0.0.0.0         255.255.255.0   U     600    0        0 wlp0s20f3

-n prints numbers instead of names. The 0.0.0.0 line is the default route: traffic for the internet leaves through 192.168.100.1, the router.

Does the gateway answer?

bash
ping -c 3 192.168.100.1 | tail -2
text
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 2.098/4.566/7.431/2.195 ms

-c 3 sends three packets and stops, and tail -2 keeps only the two summary lines. The local network works. If this fails, the problem is between the laptop and the router: the Wi-Fi link, the cable, or the router itself.

Does an internet address answer, with no names involved?

bash
ping -c 3 1.1.1.1 | tail -2
text
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 25.596/49.024/94.240/31.979 ms

Pinging an IP address skips the Domain Name System (DNS) entirely, so this tests the route to the internet on its own. Some networks block ping, so a failure here is a hint rather than proof.

Do names resolve?

bash
nslookup example.com
text
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	example.com
Address: 172.66.147.243
Name:	example.com
Address: 104.20.23.154

The IPv6 answers are cut. Server is the resolver that answered, here the one running on the laptop itself, and each Address line is an answer. If step 4 passed and this fails, the internet is fine and DNS is broken: that's the classic "the internet is down, but only for websites."

Does the service answer?

bash
curl -sI https://example.com | head -1
text
HTTP/2 200

-I asks only for the response headers, -s hides the progress meter, and head -1 keeps the status line. A 200 means the web server answered and the page exists. If everything up to here passes and the browser still fails, the problem is in the browser: an extension, a proxy setting, or its cache.

On Windows

These run in Command Prompt. Nothing here was captured on Windows, so no output is shown; the same six steps apply.

Address: ipconfig, then the "IPv4 Address" line of the adapter you use.

Route and gateway: the "Default Gateway" line of the same ipconfig output, or route print for the full table.

Gateway answers: ping followed by the gateway address. Windows sends four packets by default.

Internet answers: ping 1.1.1.1.

Names resolve: nslookup example.com.

Service answers: curl -sI https://example.com, then the first line.

On macOS

ifconfig, ping -c 3, nslookup and curl -sI work as they do on Linux; the gateway is on the default line of netstat -rn.

The same checks on Linux, Windows and macOS

CheckLinuxWindows
Addressesifconfigipconfig /all
Routes and gatewayroute -nroute print
Reachabilityping -c 4 <host>ping -n 4 <host>
Path to a hosttracepath <host>tracert <host>
Name resolutionnslookup <name>nslookup <name>
Listening portsnetstat -tulnnetstat -an
Running processesps auxtasklist
Disk spacedf -hGet-PSDrive
Recent errorsjournalctl -p err -bGet-WinEvent System -MaxEvents 20
Time since bootuptimesysteminfo (System Boot Time)

Get-PSDrive and Get-WinEvent are PowerShell; the rest of the Windows column works in Command Prompt too.

macOS runs ifconfig, ping -c, nslookup, ps aux, df -h and uptime exactly as Linux does. These are the ones that differ:

CheckmacOS
Routes and gatewaynetstat -rn
Path to a hosttraceroute <host>
Listening portslsof -iTCP -sTCP:LISTEN
Recent errorslog show --last 1h

tracepath ships with iputils on Linux and needs no root, which is why it's here in place of traceroute, often not installed by default. On newer Linux systems ip addr, ip route and ss -tuln replace ifconfig, route -n and netstat -tuln.

Reading the logs

Logs answer the question the symptom can't: what the system itself saw. journalctl -p err -b on Linux lists every error-level message since the last boot, and the Windows System log does the same for drivers and services.

Two habits make them useful:

  • Note the time the problem happened, then read the log around that time instead of from the top.
  • Search for the exact error text you noted at the start. Someone has usually logged, filed or answered it before.

Common causes, by layer

LayerWhat it looks likeFirst check
Power and hardwareNothing happens, or a device is missingIs it connected, powered, and listed by the OS?
ConnectionNo network at allCable seated, Wi-Fi radio on, link light
Address169.254.x.x, or no addressIs the DHCP server reachable?
RouteLocal network works, internet doesn'tping the gateway, then an internet IP
Name resolutionIP addresses work, names don'tnslookup against the configured resolver
ServiceOne site or app fails, others workIs the port open, is the service running?
ApplicationOnly one program failsIts own logs, settings and cache
Disk and memoryEverything is slow, saves faildf -h, Task Manager, ps aux sorted by memory

Dynamic Host Configuration Protocol (DHCP) is how a device gets its address automatically from the network, usually from the router.

Where this meets security

The same bottom-up checks are the first steps of incident response, the work of finding out what happened after something went wrong. An unexpected listening port, a process nobody recognises, a route that sends traffic somewhere new, or a resolver that changed overnight is a fault until proven otherwise, and sometimes it's an intruder. The commands are identical. The question changes: why did this change, and who changed it?