Networking Basics
How Linux machines talk to each other: ping, curl, wget, ssh, and interfaces.
On this page7 sections
Almost nothing on a modern Linux box runs in isolation - servers talk to databases, containers talk to each other, and your laptop talks to the internet. This lesson covers the handful of commands you'll reach for constantly to test and inspect those connections.
Addresses and ports
Every machine on a network has an IP address (like 192.168.1.42), and every network service on that machine listens on a numbered port. A connection is really identified by the pair: address and port.
| Port | Service |
|---|---|
| 22 | SSH (remote shell) |
| 53 | DNS (domain name lookups) |
| 80 | HTTP |
| 443 | HTTPS |
| 3306 | MySQL |
| 5432 | PostgreSQL |
DNS is the system that turns a name like example.com into an IP address, so you rarely have to type addresses by hand.
ping: is anyone there?
ping sends small ICMP "echo request" packets to a host and reports whether - and how quickly - it answers back. It's the first thing to try when something "isn't working":
ping example.com
No reply usually means either the host is down, or a firewall is silently dropping ICMP traffic (many servers do this on purpose - ping failing doesn't always mean the service itself is down).
curl and wget: talking HTTP
curl fetches a URL and prints the response - the same request your browser makes, minus the rendering:
curl https://example.com # print the response body
curl -I https://example.com # -I: headers only, no body
wget does a similar job but is built around saving what it downloads to disk rather than printing it:
wget https://example.com/file.tar.gz
A useful rule of thumb: reach for curl when you're inspecting or scripting against an API, and wget when you're downloading a file.
Interfaces: ifconfig and ip
Every network connection - your Ethernet port, your Wi-Fi card, the loopback interface used for talking to yourself - shows up as a named interface:
ifconfig # classic, older tool
ip addr # modern replacement, "ip a" for short
You'll typically see lo (loopback, always 127.0.0.1) alongside a real interface like eth0, each with its own IP address.
ssh: a remote shell
ssh opens an interactive shell on another machine over an encrypted connection - it's how almost every remote Linux server is administered:
ssh alice@203.0.113.10
The username comes before the @, the host after it. Production servers are almost always configured to accept key-based authentication instead of passwords - you'll cover exactly why, and how, in the security lesson.
Try it
ping example.com
curl example.com
curl -I example.com
ifconfig
ip addr
ssh learner@example.com
Further reading
- "TCP/IP Illustrated, Volume 1" by W. Richard Stevens (Addison-Wesley) - the definitive, detailed explanation of what actually happens on the wire.
- "The Linux Command Line" by William Shotts (No Starch Press) - its networking chapter covers these exact tools with more real-world troubleshooting examples.
Challenge
Check whether example.com is reachable with ping, then fetch only its HTTP response headers with curl. Do both in one line joined with &&.
Want to experiment first? Try things in the practice terminal (opens in a new tab), then enter the command that solves the task here.
Quiz
Lock in the concepts. Score at least 80% to mark the lesson complete.
Done with this one?
Skipped the challenge? You can mark the lesson complete by hand.