Check if computer is connected to the internet
Bash (with dnsutils), 3 bytes
Sends a DNS request for &quot;.&quot; (DNS root), exit code is 0 for success and &gt;0 otherwise.
Golfed
dig

Test
% dig &gt;/dev/null; echo $?;        
0

% nmcli nm wifi off
% dig &gt;/dev/null; echo $?;
9

Disclaimer
This will obviously only work if your DNS server is sitting in the provider's network, i.e. in the &quot;Internet&quot; (as your provider network is normally a part of it), or if your system is using a public DNS server (like 8.8.8.8 from Google, which Android based systems use), as otherwise, you can get a cached copy from a local LAN server (or localhost).
But I assume this is not against the code-golf rules, as there are obviously more than one system where this does work as intended.
Pure-HTTP methods can also give false positives, due to an intermediate caching proxy, and are not guaranteed to work everywhere, so that is not something unique to this method.
A slightly more reliable version, 8 bytes
dig +tra

(a little tribute to @Digital Trauma !)
Enables the &quot;trace mode&quot;, which will force dig to do the recursive search by itself (see https://serverfault.com/a/778830), avoiding any cache issues.