Ravindra BagaleCourses & study guides मराठी Track your progress

Linux DNS and HTTP Tools: dig, nslookup, host, curl, wget, nc and /etc/hosts with Examples

Most 'the network is down' tickets turn out to be a name problem or an HTTP problem. This chapter teaches the tools to check both from the command line: dig, nslookup and host to ask DNS; /etc/hosts and /etc/resolv.conf to see where names come from; curl and wget to talk HTTP and download files; and nc (netcat) to test whether a port is open. Every command and key option gets Why, What and How.

What you'll learn in this chapter

  • Look up names with dig, nslookup and host
  • Understand /etc/hosts, resolv.conf and nsswitch
  • Test web endpoints with curl
  • Download files with curl and wget
  • Check ports with nc
  • Tell DNS, network and app problems apart

1. An everyday example: the phone contacts list

Why do we need this?

You want to call 'Aai'. Your phone looks in your contacts first. If not there, you ask the operator's directory. Once you have the number, you dial; it may ring (someone listening), be busy, or be switched off.

What is it?

Contacts = /etc/hosts. Directory = DNS server in resolv.conf. Asking the directory = dig. Dialing and checking it rings = nc -zv. Having a conversation = curl.

How to do it (step by step)

What happens when you run curl https://shop.example.comnsswitch.conf says: check files, then dns/etc/hosts is checked for shop.example.comIf not found, the resolver in resolv.conf is askedDNS returns an IP (A or AAAA record)curl opens TCP to that IP on port 443 and does TLScurl sends the HTTP request and prints the response
Name, then connection, then TLS, then HTTP: test each step on its own.

2. dig: ask DNS directly

Why do we need this?

dig shows exactly what DNS answers, which server answered and how long the answer is cached (TTL).

What is it?

dig NAME asks for the A record. dig +short NAME prints only the answer. Add a type: A, AAAA, MX, TXT, CNAME, NS. dig @8.8.8.8 NAME asks a specific server. dig -x IP does a reverse lookup. dig +trace follows from the root down.

How to do it (step by step)

  1. Short answer.
dig +short shop.example.com

Output:

93.184.216.34

What it means: One IP.

  1. Full answer with TTL.
dig shop.example.com

Output:

shop.example.com. 300 IN A 93.184.216.34
;; SERVER: 10.0.0.2#53
;; Query time: 2 msec

What it means: Cached 300 s; asked 10.0.0.2.

  1. Mail servers.
dig +short MX example.com

Output:

10 mx1.example.com.
20 mx2.example.com.

What it means: Lower number first.

  1. Compare with public DNS.
dig +short @1.1.1.1 shop.example.com

Output:

93.184.216.40

What it means: Different: your resolver has old data.

3. nslookup and host: quick lookups

Why do we need this?

They exist on almost every system (including Windows for nslookup) and are quick to type.

What is it?

nslookup NAME [SERVER] shows the server used and the answer. host NAME gives a one-line answer; host -t MX NAME asks a type. Both come in bind-utils (RHEL) or dnsutils (Ubuntu), same as dig.

How to do it (step by step)

  1. nslookup.
nslookup db.internal

Output:

Server:  10.0.0.2
Name:    db.internal
Address: 10.0.3.40

What it means: Answered by 10.0.0.2.

  1. host.
host api.example.com

Output:

api.example.com is an alias for lb-123.elb.amazonaws.com.
lb-123.elb.amazonaws.com has address 52.1.2.3

What it means: Shows the CNAME chain.

  1. Reverse.
host 8.8.8.8

Output:

8.8.8.8.in-addr.arpa domain name pointer dns.google.

What it means: PTR record.

4. dig +trace, +norecurse and TTL: debug DNS changes

Why do we need this?

After you change a DNS record, some users see the new IP and some the old one. You need to know who is right.

What is it?

dig +trace NAME walks from the root servers to the authoritative server, so it ignores caches. dig NS domain shows the authoritative servers; dig @THAT_NS NAME gives the true current answer. The TTL number in a cached answer counts down to zero; then the resolver asks again.

How to do it (step by step)

  1. Authoritative servers.
dig +short NS example.com

Output:

a.iana-servers.net.
b.iana-servers.net.

What it means: These hold the real record.

  1. Ask them directly.
dig +short @a.iana-servers.net shop.example.com

Output:

93.184.216.40

What it means: New IP is live at the source.

  1. Cached TTL counting down.
dig shop.example.com | grep -A1 'ANSWER SECTION'

Output:

shop.example.com. 212 IN A 93.184.216.34

What it means: Old IP for 212 more seconds.

  1. Full path.
dig +trace shop.example.com | tail -3

Output:

shop.example.com. 300 IN A 93.184.216.40
;; Received 61 bytes from 199.43.135.53#53(a.iana-servers.net)

What it means: Root to answer, no cache.

5. /etc/hosts, resolv.conf and nsswitch.conf

Why do we need this?

dig works but the app still gets a different IP. That is because apps also read /etc/hosts first.

What is it?

/etc/hosts: 'IP name aliases' lines, checked before DNS. /etc/resolv.conf: nameserver and search lines (often managed by systemd-resolved or NetworkManager). /etc/nsswitch.conf 'hosts: files dns' sets the order. getent hosts NAME resolves like an app does (dig does not read /etc/hosts).

How to do it (step by step)

  1. Point a name to a test server.
echo '10.0.5.10 shop.example.com' | sudo tee -a /etc/hosts

Output:

10.0.5.10 shop.example.com

What it means: Only this machine sees it.

  1. App view vs DNS view.
getent hosts shop.example.com; dig +short shop.example.com

Output:

10.0.5.10  shop.example.com
93.184.216.34

What it means: getent uses hosts; dig does not.

  1. Which DNS server?
cat /etc/resolv.conf

Output:

search ec2.internal
nameserver 10.0.0.2

What it means: search lets you type short names.

  1. systemd-resolved status.
resolvectl status | head -5

Output:

Current DNS Server: 10.0.0.2

What it means: Real upstream server.

6. curl: talk HTTP

Why do we need this?

curl tests an API or website exactly as a client would, and shows status codes and errors clearly.

What is it?

curl URL prints the body. -I headers only (HEAD). -i headers + body. -s silent, -S show errors, -L follow redirects, -o FILE save, -O keep remote name, -w custom output like '%{http_code}'. -v shows the full conversation including TLS.

FlagMeaning
-IHeaders only
-LFollow redirects
-s -SQuiet but show errors
-o / -OSave to a file
-wPrint chosen values
-vVerbose, debug

How to do it (step by step)

  1. Headers.
curl -I https://shop.example.com

Output:

HTTP/2 200
content-type: text/html
cache-control: max-age=600

What it means: Up and cached 10 minutes.

  1. Only the status code.
curl -s -o /dev/null -w '%{http_code}\n' https://shop.example.com/health

Output:

200

What it means: Good for scripts and monitors.

  1. Timing.
curl -s -o /dev/null -w 'dns %{time_namelookup} connect %{time_connect} total %{time_total}\n' https://shop.example.com

Output:

dns 0.004 connect 0.021 total 0.380

What it means: Slow part is the server, not DNS.

  1. Follow redirects.
curl -sIL http://example.com | grep -i '^location\|^HTTP'

Output:

HTTP/1.1 301 Moved Permanently
Location: https://example.com/
HTTP/2 200

What it means: http goes to https.

7. curl for APIs: -X, -H, -d, -u

Why do we need this?

Testing a POST or an authenticated API call from a server avoids guessing whether the app or the network is wrong.

What is it?

-X METHOD sets the method (POST, PUT, DELETE). -H 'Header: value' adds headers. -d DATA sends a body (implies POST). --json DATA (curl 7.82+) sets JSON headers. -u user:pass basic auth. -k skips TLS checks (only for tests!). --resolve host:443:IP tests a server before DNS changes.

How to do it (step by step)

  1. POST JSON.
curl -s -X POST -H 'Content-Type: application/json' -d '{"sku":"A1","qty":2}' https://api.example.com/cart

Output:

{"ok":true,"items":2}

What it means: Created.

  1. Bearer token.
curl -s -H "Authorization: Bearer $TOKEN" https://api.example.com/me

Output:

{"user":"ravi"}

What it means: Token from a variable, not typed.

  1. Test a new server before DNS.
curl -sI --resolve shop.example.com:443:10.0.5.10 https://shop.example.com

Output:

HTTP/2 200

What it means: Real name, chosen IP, valid TLS.

8. curl errors you will meet

Why do we need this?

curl error messages tell you which layer failed. Learn to read them.

What is it?

Could not resolve host = DNS. Connection refused = no listener. Connection timed out = firewall/route. SSL certificate problem = TLS. HTTP 4xx = client/request issue, 5xx = server issue. curl -v shows where it stops.

How to do it (step by step)

  1. DNS.
curl https://shp.example.com

Output:

curl: (6) Could not resolve host: shp.example.com

What it means: Typo in the name.

  1. TLS.
curl https://10.0.5.10

Output:

curl: (60) SSL: no alternative certificate subject name matches target host name '10.0.5.10'

What it means: Use the name, or --resolve.

  1. Verbose.
curl -v https://shop.example.com 2>&1 | grep -E '^\* (Trying|Connected|SSL)'

Output:

* Trying 93.184.216.34:443...
* Connected to shop.example.com
* SSL connection using TLSv1.3

What it means: Each step passed.

9. wget: download files

Why do we need this?

wget is made for downloads: it resumes broken downloads and can fetch many files.

What is it?

wget URL saves with the remote name. -O FILE chooses the name. -c continues a partial file. -q quiet. -i list.txt downloads every URL in a file. --tries and --timeout control retries.

How to do it (step by step)

  1. Download.
wget https://downloads.example.com/tool-1.4.tar.gz

Output:

Saving to: 'tool-1.4.tar.gz'
100%[=======>] 12.4M 8.1MB/s in 1.5s

What it means: Saved with its name.

  1. Resume.
wget -c https://releases.example.com/ubuntu.iso

Output:

HTTP request sent... 206 Partial Content

What it means: Continues where it stopped.

  1. curl way.
curl -fLO https://downloads.example.com/tool-1.4.tar.gz

Output:

(progress bar)

What it means: -f fails on HTTP errors.

wget in depth: -O, -c, -b, -q, --limit-rate, -i and mirror

Why do we need this?

Servers have no browser. When you need an installer, a backup or a dataset on a server, wget downloads it straight from the terminal and can resume when the network drops.

What is it?

wget downloads a URL and saves it as a file. By default it keeps the name from the URL and shows a progress bar.

Common options

OptionWhat it does
-O FILESave with the name FILE (capital O).
-cContinue a half-finished download.
-bRun in the background; progress goes to wget-log.
-qQuiet: print nothing.
--limit-rate=RATECap the speed, e.g. 200k or 2m.
-i FILEDownload every URL listed in FILE.
-mMirror a site (recursive, keeps timestamps).
-P DIRSave into folder DIR.

How to do it (step by step)

  1. Save with your own name using -O.
wget -O node.tar.xz https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz

Output:

Saving to: 'node.tar.xz'
node.tar.xz   100%[=========>]  23.7M  5.1MB/s  in 4.6s

What it means: The long URL name is replaced by node.tar.xz.

  1. Resume after a drop with -c.
wget -c https://releases.ubuntu.com/24.04/ubuntu-24.04-live-server-amd64.iso

Output:

HTTP request sent, awaiting response... 206 Partial Content
Length: 2.6G, 1.1G remaining

What it means: 206 means the server sent only the missing part.

  1. Run in the background with -b.
wget -b https://files.example.com/census-2026.csv && tail -2 wget-log

Output:

Continuing in background, pid 4120.
Output will be written to 'wget-log'.

What it means: You get the prompt back. Read wget-log to see progress.

  1. Stay silent in scripts with -q.
wget -q https://files.example.com/rates.json && echo saved

Output:

saved

What it means: No progress bar. Check $? or use && to know it worked.

  1. Do not eat the office bandwidth: --limit-rate.
wget --limit-rate=300k https://files.example.com/training.mp4

Output:

training.mp4   12%[=>        ]  52M  300KB/s

What it means: The speed stays near 300 KB/s so others can work.

  1. Download a list with -i.
printf "https://files.example.com/a.pdf\nhttps://files.example.com/b.pdf\n" | tee list.txt; wget -i list.txt

Output:

FINISHED --10:21:07--
Downloaded: 2 files, 410K in 0.3s

What it means: One URL per line; wget fetches them one by one.

  1. Copy a small docs site with --mirror.
wget --mirror --convert-links --no-parent https://help.example.com/manual/

Output:

FINISHED --10:30:44--
Downloaded: 38 files, 2.1M

What it means: A folder help.example.com/ now holds an offline copy. --convert-links makes links work offline.

Practise this in the tasks below: Practice tasks

10. nc (netcat): is the port open?

Why do we need this?

ping only tests ICMP. nc tests the real TCP port your app needs, in one second.

What is it?

nc -zv HOST PORT: -z scan only (no data), -v verbose. -w 3 sets a timeout. -u for UDP. nc -l 9000 listens (to test a firewall from the other side). On RHEL, nc is the nmap-ncat package. Bash also has /dev/tcp/HOST/PORT.

How to do it (step by step)

  1. Open port.
nc -zv -w 3 10.0.3.40 5432

Output:

Ncat: Connected to 10.0.3.40:5432.

What it means: Database port reachable.

  1. Closed port.
nc -zv -w 3 10.0.3.40 6379

Output:

Ncat: Connection refused.

What it means: Nothing listens there.

  1. Firewall test both sides.
nc -l 9000   (on server B)
nc -zv B 9000   (on server A)

Output:

Ncat: Connected to B:9000.

What it means: Path and firewall allow 9000.

  1. Without nc.
timeout 3 bash -c '</dev/tcp/10.0.3.40/5432' && echo open

Output:

open

What it means: Works on minimal images.

11. Real examples from many industries

Why do we need this?

The same Linux skill shows up in every kind of company. Seeing it in many places helps you remember it.

What is it?

Each row is a made-up team. It shows who uses this and how.

How to do it (step by step)

Team and cityHow they use itCommand
Sneha, travel portal, PuneChecks status codes in a health scriptcurl -s -o /dev/null -w '%{http_code}'
Mark, media, TorontoTests new servers with --resolve before DNS cutovercurl --resolve shop.example.com:443:10.0.5.10
Fatima, telecom, DubaiFinds stale DNS by comparing resolversdig +short @1.1.1.1 NAME
Ola, fintech, OsloProves firewall rules with ncnc -zv -w 3 10.0.3.40 5432
Ken, factory IoT, NagoyaDownloads firmware with resumewget -c URL
Aditya, startup, KolhapurUses /etc/hosts for local testinggetent hosts shop.example.com

12. Common errors and how to fix them

Why do we need this?

Everyone hits these errors. Knowing the cause saves hours.

What is it?

Read the exact message first. Then match it to a row below.

How to do it (step by step)

Error you seeWhy it happensHow to fix
curl: (6) Could not resolve hostDNS lookup failed or typoCheck name and resolver.
dig +short NAME
curl: (7) Failed to connect ... Connection refusedNo listener on the portCheck the service on the target.
sudo ss -ltnp
curl: (28) Connection timed outFirewall, security group or routeTest with nc, check rules.
nc -zv -w 3 HOST PORT
curl: (60) SSL certificate problemWrong name, expired or untrusted certCheck the cert; never use -k in production.
curl -v https://HOST
dig: command not foundbind-utils/dnsutils missingInstall it.
sudo dnf install -y bind-utils
dig works but app gets old IP/etc/hosts entry or app cacheCheck how the app resolves.
getent hosts NAME
status: SERVFAILDNS server could not answer (DNSSEC or upstream)Try another resolver.
dig @8.8.8.8 NAME
status: NXDOMAINName does not existCheck spelling or the zone.
dig NAME +trace
HTTP/1.1 403 ForbiddenServer refused: permissions or WAFCheck auth headers and server rules.
curl -i -H 'Authorization: Bearer ...' URL
HTTP/1.1 502 Bad GatewayProxy cannot reach the backendCheck the backend port from the proxy.
nc -zv 127.0.0.1 3000

13. Troubleshooting step by step

Why do we need this?

Split the problem: name, connect, TLS, HTTP.

What is it?

Go top to bottom. Stop at the first step that shows the problem.

How to do it (step by step)

  1. Name resolves like the app?
getent hosts NAME
  1. DNS answer and server?
dig NAME
  1. Port reachable?
nc -zv -w 3 HOST 443
  1. TLS ok?
curl -vI https://NAME
  1. HTTP status?
curl -s -o /dev/null -w '%{http_code}' https://NAME
  1. Where is time spent?
curl -s -o /dev/null -w '%{time_namelookup} %{time_connect} %{time_total}' https://NAME

14. Lab 1: Follow a name from hosts to DNS

Why do we need this?

See how /etc/hosts overrides DNS for apps but not for dig.

What is it?

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

How to do it (step by step)

  1. DNS answer.
dig +short example.com

Output:

93.184.216.34
  1. Add an override.
echo '127.0.0.1 example.com' | sudo tee -a /etc/hosts

Output:

127.0.0.1 example.com
  1. App view.
getent hosts example.com

Output:

127.0.0.1  example.com
  1. dig still says DNS.
dig +short example.com

Output:

93.184.216.34
  1. Remove the line.
sudo sed -i '/127.0.0.1 example.com/d' /etc/hosts

Output:

(no output)

15. Lab 2: Test a web service layer by layer

Why do we need this?

Run a tiny local web server and test it with nc and curl.

What is it?

A full hands-on lab. Run every step on a test Linux machine (an EC2 instance, a VM, or WSL).

How to do it (step by step)

  1. Start a server.
python3 -m http.server 8000 --bind 127.0.0.1

Output:

Serving HTTP on 127.0.0.1 port 8000
  1. In another terminal, check the port.
nc -zv 127.0.0.1 8000

Output:

Connected to 127.0.0.1:8000
  1. Headers.
curl -I http://127.0.0.1:8000/

Output:

HTTP/1.0 200 OK
  1. A missing file.
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/nope

Output:

404
  1. Stop it and retry.
curl http://127.0.0.1:8000/

Output:

curl: (7) Failed to connect ... Connection refused

Ravindra Bagale's Tip

Use getent hosts NAME, not only dig, when an app gets the 'wrong' IP. dig asks DNS directly and skips /etc/hosts, but your app follows nsswitch.conf and reads /etc/hosts first.

16. Frequently asked questions

Q. dig or nslookup?

dig for detail and scripts; nslookup is fine for quick checks.

Q. What is TTL?

How many seconds resolvers may cache the answer.

Q. curl or wget?

curl for APIs and testing; wget for simple or resumable downloads.

Q. Is curl -k safe?

Only for quick tests; it disables certificate checks.

Q. Why does DNS change take time?

Old answers stay cached until TTL expires.

Q. nc not found on RHEL?

Install nmap-ncat.

Q. How to test UDP?

nc -zvu HOST PORT, but results are less reliable.

Q. Where are DNS servers set?

resolv.conf, often generated by systemd-resolved or NetworkManager.

17. Interview questions and answers

Beginner level

Q. Get only the IP of a name?

dig +short NAME.

Q. Show HTTP headers?

curl -I URL.

Q. Download a file?

wget URL or curl -O URL.

Q. Test a TCP port?

nc -zv HOST PORT.

Mid level level

Q. Why might dig and ping show different IPs?

ping uses /etc/hosts via nsswitch; dig asks DNS only.

Q. Print only the HTTP status?

curl -s -o /dev/null -w '%{http_code}' URL.

Q. Query a specific DNS server?

dig @SERVER NAME.

Q. Resume a download?

wget -c URL.

Senior level

Q. Test a new load balancer before DNS cutover?

curl --resolve name:443:IP to keep SNI and cert checks.

Q. Lower TTL before migration, why?

So clients pick up the new IP quickly.

Q. Measure where latency comes from?

curl -w timings: namelookup, connect, appconnect, starttransfer.

Q. 502 from nginx: steps?

Check upstream port with nc from the proxy, upstream logs, and timeouts.

Try at home

  1. Look up A, MX and TXT records of three domains with dig and note their TTLs.
  2. Write a one-line curl that prints status and total time for a site, and run it five times.

Practice Tasks

About this scenario

Vidarbha Cotton Mills is a textiles business in Nagpur. Ganesh Wankhede looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 23

Easy IPv6 record

Why: Names and HTTP break more often than cables.

What to do: Get only the IPv6 address of example.org.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy TXT records

Why: Names and HTTP break more often than cables.

What to do: Show only the TXT records of example.org.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy host for MX

Why: Names and HTTP break more often than cables.

What to do: Use host to get the mail servers of example.org.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy nslookup a name

Why: Names and HTTP break more often than cables.

What to do: Look up intranet.local with nslookup.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Headers only

Why: Names and HTTP break more often than cables.

What to do: Show only the headers of https://example.org.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Save as

Why: Names and HTTP break more often than cables.

What to do: Download https://example.org/a.zip and save as pkg.zip with curl.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy wget with a name

Why: Names and HTTP break more often than cables.

What to do: Download https://example.org/x.tgz and save as tool.tgz with wget.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Port check

Why: Names and HTTP break more often than cables.

What to do: Check if port 6379 on 10.0.4.9 is open, verbose, scan only.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Silent download

Why: Names and HTTP break more often than cables.

What to do: Download https://example.org/agent.rpm with wget and print nothing.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Download a list

Why: Names and HTTP break more often than cables.

What to do: Download every URL listed in the file mirrors.txt with wget.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Ask Quad9

Why: Names and HTTP break more often than cables.

What to do: Ask DNS server 9.9.9.9 for api.example.org, short answer.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Reverse lookup

Why: Names and HTTP break more often than cables.

What to do: Find the name for IP 1.1.1.1 with dig.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Authoritative servers

Why: Names and HTTP break more often than cables.

What to do: List the name servers of example.org, short.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium App view of a name

Why: Names and HTTP break more often than cables.

What to do: Resolve billing.internal the way apps do (hosts file included).

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Follow redirects headers

Why: Names and HTTP break more often than cables.

What to do: Show headers of http://example.org while following redirects.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium DELETE request

Why: Names and HTTP break more often than cables.

What to do: Send a DELETE request to https://api.example.org/items/9.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Resume

Why: Names and HTTP break more often than cables.

What to do: Resume the download of https://example.org/big.iso.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Listen

Why: Names and HTTP break more often than cables.

What to do: Listen on TCP port 7000 with nc to test a firewall.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Download in background

Why: Names and HTTP break more often than cables.

What to do: Download https://example.org/dump.sql.gz in the background with wget.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Medium Slow download

Why: Names and HTTP break more often than cables.

What to do: Download https://example.org/video.mp4 with wget at most 500k per second.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Just the code

Why: Names and HTTP break more often than cables.

What to do: Print only the HTTP status code of https://example.org/status, discarding the body.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Test before DNS

Why: Names and HTTP break more often than cables.

What to do: Fetch headers of https://pay.example.org but connect to 10.0.6.6.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Hard Mirror a site

Why: Names and HTTP break more often than cables.

What to do: Make an offline mirror of https://docs.example.org/ with wget.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

In short

  1. dig, nslookup and host ask DNS.
  2. /etc/hosts comes first for apps; getent shows the app view.
  3. curl -I, -L, -w, -v test HTTP.
  4. curl -X, -H, -d test APIs; --resolve tests before DNS.
  5. wget -c resumes downloads.
  6. nc -zv tests ports.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

dig in 4 steps. Check DNS. +short for just the answer. @server to ask another DNS. Mail servers.
Revision card: dig in 4 steps · Download PNG · Open card page
curl checks. Test HTTP from the server. -I headers, -L follow. -v shows TLS and timing. Headers only.
Revision card: curl checks · Download PNG · Open card page
dig vs nslookup. Full DNS detail, TTL. / Simple answer.
Comparison: dig vs nslookup · Download PNG · Open card page
curl vs wget. APIs, headers, any method. / Downloads, resume, mirror.
Comparison: curl vs wget · Download PNG · Open card page
Name does not resolve?. Check resolv.conf and hosts. Ask another server. Compare.
Interview card: Name does not resolve? · Download PNG · Open card page
/etc/hosts vs DNS?. hosts is local, checked first. Order is in nsswitch.conf. App view.
Interview card: /etc/hosts vs DNS? · Download PNG · Open card page
curl vs wget?. curl: APIs, headers, methods. wget: downloads, resume, mirror. Resume.
Interview card: curl vs wget? · Download PNG · Open card page
Why old IP after DNS change?. Caches keep it until TTL ends. Lower TTL before changes. See TTL.
Interview card: Why old IP after DNS change? · Download PNG · Open card page

More cards: Ravi Sir's Cards.