Bird
Raised Fist0
Linux CLIscripting~5 mins

Why network tools diagnose connectivity in Linux CLI - Why It Works

Choose your learning style10 modes available
Introduction
Sometimes your computer cannot reach websites or other computers. Network tools help find where the problem is by checking if your device can talk to others on the network.
When a website does not load and you want to check if your internet is working
When you cannot connect to a company server and need to see if the server is reachable
When you want to check if your home router is responding
When you want to see if a specific port on a server is open and accepting connections
When you want to measure how long it takes for data to travel to another computer
Commands
This command sends 4 small messages to Google's DNS server to check if your computer can reach it and how long it takes.
Terminal
ping 8.8.8.8 -c 4
Expected OutputExpected
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=14.2 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=14.0 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=13.9 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=14.1 ms --- 8.8.8.8 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 13.900/14.050/14.200/0.114 ms
→
-c - Limits the number of ping messages sent
This command shows the path your messages take to reach Google's DNS server, helping find where delays or blocks happen.
Terminal
traceroute 8.8.8.8
Expected OutputExpected
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.123 ms 1.045 ms 1.012 ms 2 10.10.0.1 (10.10.0.1) 10.234 ms 10.198 ms 10.167 ms 3 172.217.0.1 (172.217.0.1) 14.345 ms 14.312 ms 14.280 ms 4 8.8.8.8 (8.8.8.8) 14.123 ms 14.098 ms 14.067 ms
This command checks if the web server on google.com is accepting connections on port 80 (the standard web port).
Terminal
nc -zv google.com 80
Expected OutputExpected
Connection to google.com 80 port [tcp/http] succeeded!
→
-z - Scan without sending data
→
-v - Show verbose output
Key Concept

If you remember nothing else from this pattern, remember: network tools help find where communication stops between your computer and others.

Common Mistakes
Not specifying the number of ping packets and letting it run forever
The ping command will keep running until stopped manually, which can be confusing and waste resources
Use the -c flag to limit the number of ping packets, like ping 8.8.8.8 -c 4
Using traceroute without root permissions on some systems
Traceroute may fail or show incomplete results if not run with proper permissions
Run traceroute with sudo if needed, like sudo traceroute 8.8.8.8
Trying to check a port with nc without the -z flag
Without -z, nc tries to send data, which may cause unexpected behavior or hang
Use nc -zv to just check if the port is open without sending data
Summary
Use ping to check if a device is reachable and measure response time.
Use traceroute to see the path and find where delays or blocks occur.
Use nc with -zv to check if a specific port on a server is open.

Practice

(1/5)
1. What is the main purpose of using network tools like ping and traceroute?
easy
A. To change your computer's screen resolution
B. To install new software on your computer
C. To delete files from your system
D. To check if your computer can reach another device or website

Solution

  1. Step 1: Understand what network tools do

    Network tools like ping and traceroute test connectivity between your computer and other devices or websites.
  2. Step 2: Identify the correct purpose

    They help find if a connection is working or where it might be failing, not for installing software or changing settings unrelated to networking.
  3. Final Answer:

    To check if your computer can reach another device or website -> Option D
  4. Quick Check:

    Network tools diagnose connectivity = A [OK]
Hint: Network tools test connection, not system settings [OK]
Common Mistakes:
  • Thinking network tools install software
  • Confusing network tools with system utilities
  • Assuming network tools change display settings
2. Which of the following is the correct syntax to send 4 ping requests to example.com?
easy
A. ping -c 4 example.com
B. ping example.com -count 4
C. ping /n 4 example.com
D. ping example.com -4

Solution

  1. Step 1: Recall ping command options

    The option -c specifies the count of ping requests in Linux.
  2. Step 2: Match correct syntax

    Only ping -c 4 example.com uses the correct option and order.
  3. Final Answer:

    ping -c 4 example.com -> Option A
  4. Quick Check:

    Count option for ping = -c [OK]
Hint: Use -c to set ping count in Linux [OK]
Common Mistakes:
  • Using Windows ping options on Linux
  • Placing options after the hostname incorrectly
  • Using wrong option flags like /n or -count
3. What output will you get when running ping -c 1 8.8.8.8 if the network is working?
medium
A. Request timed out.
B. Permission denied
C. 1 packets transmitted, 1 received, 0% packet loss
D. Unknown host 8.8.8.8

Solution

  1. Step 1: Understand ping output on success

    If the network works, ping shows packets sent and received with 0% loss.
  2. Step 2: Identify correct output

    1 packets transmitted, 1 received, 0% packet loss matches the success message showing 1 packet sent and received with no loss.
  3. Final Answer:

    1 packets transmitted, 1 received, 0% packet loss -> Option C
  4. Quick Check:

    Successful ping = packets received with 0% loss [OK]
Hint: Success ping shows packets received and 0% loss [OK]
Common Mistakes:
  • Confusing timeout message with success
  • Thinking unknown host means network is fine
  • Ignoring packet loss details
4. You run traceroute google.com but get the error: command not found. What is the best way to fix this?
medium
A. Install the traceroute tool using your package manager
B. Restart your computer
C. Use ping google.com instead
D. Change your DNS server settings

Solution

  1. Step 1: Understand the error meaning

    command not found means traceroute is not installed or not in PATH.
  2. Step 2: Fix by installing traceroute

    Installing traceroute with the package manager adds the command to your system.
  3. Final Answer:

    Install the traceroute tool using your package manager -> Option A
  4. Quick Check:

    Missing command = install tool [OK]
Hint: Install missing tools when command not found error appears [OK]
Common Mistakes:
  • Restarting without checking installation
  • Using ping when traceroute is needed
  • Changing DNS without cause
5. You want to check if your computer's network interface has an IP address assigned. Which command helps diagnose this?
hard
A. ping 127.0.0.1
B. ip addr show
C. nslookup google.com
D. traceroute 8.8.8.8

Solution

  1. Step 1: Understand what each command does

    ip addr show displays network interfaces and their IP addresses. ping 127.0.0.1 tests local network stack. nslookup checks DNS resolution. traceroute traces route to a host.
  2. Step 2: Identify command to check IP address

    Only ip addr show directly shows assigned IP addresses on interfaces.
  3. Final Answer:

    ip addr show -> Option B
  4. Quick Check:

    Check IP address = ip addr show [OK]
Hint: Use ip addr show to see IP addresses on interfaces [OK]
Common Mistakes:
  • Using ping to check IP assignment
  • Confusing DNS lookup with IP address check
  • Using traceroute for interface info
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard