← Back to course

Networking from the Terminal

Networking from the Terminal

Welcome back.

In the previous lesson, you learned how to watch processes and monitor your system.

Now we go outside your computer.

Into the network.

Because your machine does not live alone. It talks to routers, servers, websites, APIs, package repositories, and sometimes one printer that refuses to cooperate because printers are basically cursed furniture.

What You’ll Learn

In this lesson, you’ll learn how to:

The Mission

Your mission is simple:

Use the terminal to answer these questions:

Test a Connection with ping

The ping command checks if a host is reachable.

Try:

ping -c 4 example.com

The -c 4 option means “send 4 packets”.

You may see something like:

64 bytes from example.com: icmp_seq=1 ttl=56 time=22.4 ms
64 bytes from example.com: icmp_seq=2 ttl=56 time=21.9 ms
64 bytes from example.com: icmp_seq=3 ttl=56 time=22.1 ms
64 bytes from example.com: icmp_seq=4 ttl=56 time=22.0 ms

This means your computer can reach example.com.

If it fails, it may mean:

ping is not perfect, but it is a good first check.

Like asking: “Hello, internet, are you alive?”

Ping an IP Address

Try pinging a public IP address:

ping -c 4 1.1.1.1

If this works, but this fails:

ping -c 4 example.com

then your internet may work, but DNS may be broken.

DNS is what turns names like example.com into IP addresses.

Without DNS, the internet becomes a city where every building has only coordinates and no names.

Very technical.

Very annoying.

Fetch a Webpage with curl

curl lets you make web requests from the terminal.

Try:

curl https://example.com

You will see the HTML of the page.

It may look messy.

That is normal.

HTML is what websites are made of. Sometimes beautiful in the browser, terrifying in the terminal.

Show Only Headers

To show only HTTP headers, use:

curl -I https://example.com

You may see:

HTTP/2 200
content-type: text/html
server: ...

The status code is important.

Common examples:

200 = OK
301 = moved permanently
403 = forbidden
404 = not found
500 = server error

If you work with websites or APIs, curl becomes your little truth machine.

Browsers can hide things.

curl does not care about feelings.

Check Your IP Addresses

To see your network interfaces and IP addresses, use:

ip addr

You may see interfaces like:

lo
wlan0
eth0
enp3s0

Common meanings:

Look for something like:

inet 192.168.1.35/24

That is your local IP address.

Your local IP is used inside your home or office network.

It is not usually your public internet IP.

Check the Default Route

To see where your traffic goes by default, use:

ip route

You may see something like:

default via 192.168.1.1 dev wlan0

This means your computer sends internet traffic through 192.168.1.1.

That is usually your router.

The router is the small box that pretends to be simple but secretly controls your whole digital life.

Check Open Ports with ss

The ss command shows sockets and network connections.

To see listening TCP and UDP ports:

ss -tuln

You may see something like:

Netid State  Local Address:Port
tcp   LISTEN 0.0.0.0:3000
tcp   LISTEN 127.0.0.1:5432

This tells you which services are listening.

Examples:

This is very useful when your app says:

“Server is running.”

but the browser says:

“No, it is not.”

One of them is lying.

ss helps you investigate.

Check If a Local Server Is Running

If your app runs on port 3000, try:

curl http://localhost:3000

Or check listening ports:

ss -tuln | grep 3000

If you see a result, something is listening on port 3000.

If you see nothing, your server is probably not running.

The terminal has spoken.

Coldly, but clearly.

Basic DNS Check

To check if a domain name resolves, you can use:

getent hosts example.com

You may see:

93.184.216.34 example.com

This means your system can resolve the domain.

If this fails, DNS may be the problem.

DNS problems are special because the internet may be working, but names do not work.

It is like having a phone but forgetting everyone’s name.

Common Mistakes

Thinking ping always proves everything

Some servers block ping.

So if this fails:

ping -c 4 example.com

it does not always mean the website is down.

Try:

curl -I https://example.com

Always test more than one way.

The network is not a single door.

It is a building with too many corridors.

Confusing local IP and public IP

Your local IP may look like:

192.168.1.35

Your public IP is what the outside internet sees.

They are not the same.

Your router usually stands between them.

Like a bouncer at a club, but with blinking lights.

Forgetting that ports matter

A server can be running, but on a different port.

For example:

http://localhost:3000
http://localhost:8080
http://localhost:5173

These are different addresses because the ports are different.

Port numbers matter.

The browser is not psychic.

Practice

Try this:

ping -c 4 example.com
ping -c 4 1.1.1.1
curl -I https://example.com
ip addr
ip route
ss -tuln
getent hosts example.com

Then answer:

  1. What does ping test?
  2. What does curl -I show?
  3. Which command shows your IP addresses?
  4. Which command shows the default route?
  5. Which command shows listening ports?

Mini Challenge

Start a local development server if you have one.

For example, in a Next.js project:

npm run dev

Then, in another terminal:

ss -tuln | grep 3000
curl http://localhost:3000

If your app uses another port, replace 3000 with the correct port.

Congratulations.

You are now checking your local web server like a serious person.

Dangerous progress.

Summary

Today you learned:

Networking from the terminal is a powerful skill.

It helps you understand whether a problem is in your code, your server, your router, DNS, or the mysterious swamp called “the internet”.

Next Lesson

In the next lesson, we’ll learn about archives and compression.

We’ll pack files, unpack them, and finally understand what those .tar.gz things are.

Spoiler: not pasta.