What is a network?
A network is a group of devices that can talk to each other: your laptop, your phone, the family printer, and the router that connects them all to the internet. When you load a website, your computer doesn't grab one giant file. It sends and receives lots of tiny chunks of data called packets that travel back and forth between your device and a far-away server.
In the Command Line Interface tutorial, you used the CLI to explore files and programs on your own computer. But the CLI can reach way past your keyboard. With a few network commands you can see your computer's network settings, test whether another machine is reachable, and even watch the exact route your packets take across the internet.
New here? This tutorial builds on the command line basics. If words like "terminal" and "command" feel new, do the Command Line Interface tutorial first, then come back.
Why bother? Because networks break. The wifi drops, a website won't load, a game keeps lagging. Network commands turn "the internet is broken!" into an actual investigation: is the problem my computer, my router, or the website itself? By the end of this page you'll know exactly which command answers which question.
Two kinds of addresses: IP and MAC
For packets to find their way, every device needs an address. Devices actually have two, and they do different jobs:
- Like your street address: it says where you are on the network right now
- Assigned by the network, so it can change when you join a new one
- What packets use to find your device
- Like a serial number: it identifies the device's network hardware itself
- Burned in at the factory, so it stays the same everywhere
- Used by devices talking on the same local network
Think of it this way: if your laptop moves from home to school, its street address (IP) changes because it lives somewhere new, but its serial number (MAC) is still the same laptop. In a minute you'll use a command that shows you both.
How the internet finds a website
You type codehs.com, not 34.213.108.87. But packets only understand numbers. So every website visit starts with a quick translation, then a relay race:
You type a name
You ask your browser for a website by its human-friendly name.
codehs.comDNS looks up the IP
A DNS server works like the internet's phone book and returns the number.
34.213.108.87Packets hop to it
Your packets jump router to router until they reach that IP, then the reply hops back.
6 hops, 61 msEach router your packet passes through is called a hop. Routers use a routing table, basically a map, to decide where to send each packet next. Your request might hop through your home router, your internet provider, and several big internet backbones before it arrives, usually in well under a tenth of a second.
The network commands
Here are the five commands every network detective keeps in their belt. The exact names vary a little by operating system: Mac and Linux use ifconfig and traceroute, while Windows uses ipconfig and tracert. Same ideas, slightly different spelling.
ifconfig / ipconfig Is it me?
Shows the network settings of your own computer: its IP address, its MAC address, and whether each network adapter (like wifi) is up and running. If a page won't load, start here. No IP address usually means you're not really connected to the network at all.
With admin (superuser) permissions, these commands can even turn network adapters on and off.
ping Can I reach it?
Sends small test packets to another computer and waits for replies, like shouting "Marco!" and listening for "Polo!" Each reply shows the round-trip time in milliseconds. When you stop, you get statistics: how many packets made it and how many were lost. Replies mean the site is reachable. Timeouts mean something between you and it is broken.
traceroute / tracert Which path?
Follows your packets on their journey and prints every hop along the way with how long it took. It's a road map of your request crossing the internet. If a connection is slow or failing, traceroute shows you where along the route things go wrong. (Windows also has pathping, which combines tracert with ping to find hops that delay or drop packets.)
netstat Who's connected?
Lists all the active connections and listening ports on your computer: every conversation your machine is currently having over the network. It can also display the routing table. Security pros love this one for spotting connections that shouldn't be there.
nslookup What's its number?
Asks a DNS server to translate a website name into its IP address, the "phone book lookup" from the diagram above. If nslookup fails but ping to a raw IP works, you know the problem is DNS, not your connection.
The detective's order: wifi acting up? Try ifconfig (is my computer connected?), then ping a website (can I reach the outside world?), then traceroute (where exactly does it break?). Three commands, mystery solved.
Try it: your network terminal
Welcome to your own network operations terminal. It simulates a real one, so nothing you type here can break the internet. Complete these missions (stuck? reveal a hint):
1Find your computer's IP address
Use the command that shows your own machine's network settings. Bonus: spot the MAC address too.
2Check if codehs.com is reachable
Send test packets to codehs.com and read the statistics. Then try ping brokensite.test to see what a failure looks like.
3Count the hops to codehs.com
Trace the route your packets take. How many routers do they pass through, and how does the time change with each hop?
Click the terminal, type a command, and press Enter. Type help to list every command it understands, and clear to wipe the screen. Press the up arrow to repeat a command.
Command reference
Keep this table handy the next time the wifi gets weird. Mac/Linux names are listed first with the Windows version after the slash.
| Command | What it shows | Example |
|---|---|---|
| ifconfig / ipconfig | Your own computer's network settings: IP address, MAC address, adapter status | ifconfig |
| ping | Whether another computer is reachable, reply times, and how many packets were lost | ping codehs.com |
| traceroute / tracert | Every router hop your packets pass through on the way, with timing for each | traceroute codehs.com |
| pathping | Windows combo of tracert + ping: finds hops with delays or packet loss | pathping codehs.com |
| netstat | All active connections and listening ports; can also show the routing table | netstat |
| nslookup | The IP address behind a website name (a DNS lookup) | nslookup codehs.com |
| netsh / networksetup | Tools for changing network settings (needs admin permissions) | netsh interface show interface |
Quick quiz
1. Your wifi seems broken and you want to check your OWN computer's IP address first. Which command do you run?
2. You run ping brokensite.test and every packet says "Request timeout", ending with 100% packet loss. What does that tell you?
3. Which address works like a serial number that stays with a device's hardware, even when it joins a different network?
Keep exploring cybersecurity
You can now read a network like a map: check your own settings, ping a host, and trace packets across the internet. Keep sharpening those command line skills, or start investigating like a digital detective.