ping, curl and wget: network commands
A few commands answer most questions about a network: is it reachable, what is my address, and can I fetch this file? They were not run for this page, since the results would describe a real network. Sample outputs are illustrations.
ping: is it reachable?
ping -c 4 example.comPING example.com (93.184.215.14): 56 data bytes
64 bytes from 93.184.215.14: icmp_seq=0 ttl=56 time=18.4 ms
64 bytes from 93.184.215.14: icmp_seq=1 ttl=56 time=17.9 ms
64 bytes from 93.184.215.14: icmp_seq=2 ttl=56 time=18.6 ms
64 bytes from 93.184.215.14: icmp_seq=3 ttl=56 time=18.1 ms
--- example.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet lossOn Linux and the Mac, ping carries on for ever unless you give -c with a count, or press Ctrl + C. Each line is one reply, with the time taken. The summary gives the share lost.
| You see | It usually means |
|---|---|
| steady replies | the connection is fine |
| "Request timeout" or no replies | the other end is off, unreachable, or ignores pings |
| "cannot resolve" or "Name or service not known" | the name could not be found: a DNS problem |
| "Network is unreachable" | your own computer has no connection |
Test in three steps: your router, then a public address by number, then a site by name. Where the replies stop tells you where the fault is.
What is my address?
ip addr
hostname -IOn Linux, ip addr lists each network interface with its addresses. Look for the line beginning inet under your Wi-Fi or Ethernet interface. hostname -I prints just the addresses.
On a Mac, use ifconfig, or for one answer: ipconfig getifaddr en0.
These are the addresses on your local network. The address the internet sees is your router's.
curl: fetch from a web address
curl requests a web address and prints what comes back.
curl https://example.comThat prints the page's HTML. More useful forms:
| Command | Does |
|---|---|
curl -I URL | show only the headers: status, type, size |
curl -o file URL | save to a file with the name you give |
curl -O URL | save using the name from the address |
curl -L URL | follow redirects |
curl -s URL | silent: no progress display |
curl -C - -O URL | resume an interrupted download |
curl -I https://example.com
curl -L -o page.html https://example.comThe first line of the headers is the status. 200 means success, 301 and 302 mean the page has moved, 404 means not found, and numbers from 500 mean the server has a problem.
wget: download files
wget is made for downloading. It saves to a file by default and retries if the connection drops.
wget https://example.com/file.zip
wget -c https://example.com/file.zip-c continues a partial download. wget comes with most Linux systems. The Mac has curl but not wget unless you install it.
Never pipe a download into a shell without reading it
Installation instructions often look like this:
curl -sSL https://example.com/install.sh | shDanger. That line downloads a program from the internet and runs it at once, with your permissions, without your seeing a word of it. With sudo in it, the program has full control of the computer. Do this only for software you have decided to trust, from its official site, over https. The careful way is to download first, read, and then run: curl -o install.sh URL, then less install.sh, then sh install.sh.
DNS: names into addresses
nslookup example.com
dig example.com +shortBoth ask a DNS server for the address behind a name. If these fail while pinging a numeric address works, the trouble is with name lookup, not the connection.
traceroute: the route
traceroute example.comIt lists each router on the way to the destination. Lines of stars are routers that did not answer, which is common. What matters is where replies stop for good. On Linux it may need installing. tracepath is a close relative that is usually present.
Open ports and connections
ss -tulnOn Linux, ss -tuln lists the ports on which your computer is listening for connections. The older netstat -tuln does the same where it is installed. On a Mac, lsof -i -P | grep LISTEN.
ssh: a terminal on another computer
ssh user@host opens a command line on a remote computer that you have an account on. It asks for the password, or uses a key file. exit closes the connection. scp file user@host:folder/ copies a file to it.
Stay within your own network
Testing your own connection and your own computers is fine. Scanning or probing systems that belong to someone else, without their permission, may be against the law and against your internet provider's terms. If you are learning, practise on your own machines.
The Windows equivalents are ipconfig, ping and tracert.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.