Skip to main content
Linux Command Line – Complete Beginner to Advanced Guide
CHAPTER 10 Beginner

Linux Networking Commands

Updated: May 16, 2026
20 min read

# CHAPTER 10

Linux Networking Commands

1. Introduction

A Linux server operating in isolation is a useless metal box. The entire purpose of a server is to communicate—to serve web pages, route database queries, and establish secure tunnels across the globe. When a user submits an IT ticket stating, "The web application is down," the problem could be a broken physical cable, a misconfigured firewall, or a crashed DNS server. To diagnose the fault, you cannot rely on visual network maps; you must probe the digital ether using the command line. In this chapter, we will master the essential Linux networking toolkit. We will test connectivity with ping, interact with web APIs using curl, download files via wget, verify open ports, and establish remote control using the omnipresent ssh protocol.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Verify local IP configurations using the modern ip a command.
  • Test Layer 3 network connectivity and latency using ping.
  • Isolate path routing failures using traceroute.
  • Interact with web servers and APIs directly from the terminal using curl.
  • Download files from the internet without a browser using wget.
  • Identify listening services and open ports using netstat or ss.
  • Securely log into remote servers using ssh.

3. Checking Your Own Network (ip)

Before blaming the internet, you must check your own machine. Does your Linux server even have an IP address? Historically, administrators used the ifconfig command. Today, this is deprecated. The modern standard is the ip command.
bash
12
# Display your IP address and network interfaces
ip a

Look for the interface named eth0 or enp3s0. Below it, you will see your inet (IPv4 address), proving you are connected to the local network.

4. Testing Connectivity (ping and traceroute)

1. The Ping Command: ping sends a tiny ICMP radar pulse to a destination to see if it is alive.
bash
1
ping google.com

*Note for Windows users:* In Windows, a ping stops after 4 tries. In Linux, a ping will run *forever* until you press Ctrl + C to stop it.

  • *Pro-tip:* If ping 8.8.8.8 succeeds, but ping google.com says "Temporary failure in name resolution," your internet works, but your DNS is broken!

2. The Traceroute Command: If a ping fails, you need to know exactly which router dropped the packet. traceroute lists every physical "hop" your packet takes across the global internet.

bash
1
traceroute google.com

5. Interacting with the Web (curl and wget)

A headless Linux server does not have Google Chrome. How do you test a website or download a file?

1. Testing Web Servers (curl): curl is a magic wand for interacting with HTTP. If you type curl example.com, the terminal will print the raw HTML code of the website directly onto your screen. It proves the web server is answering requests.

bash
12
# Ask a public API for data (e.g., checking the weather via the terminal)
curl wttr.in

2. Downloading Files (wget): If you need to download a software installation package from the internet, you use wget.

bash
12
# Download a zip file directly to your current folder
wget https://example.com/software.zip

6. Checking Open Ports (netstat / ss)

If you start a web server, how do you mathematically prove it is actually listening for traffic on Port 80? You use Socket Statistics (ss) or the legacy netstat command.
bash
12
# Show all listening TCP ports and the programs using them
sudo ss -tulpn

If you do not see Port 80 in the output, your web server has crashed, and no firewall rule in the world will fix it.

7. Remote Control (ssh)

You will rarely sit physically in a freezing datacenter plugging a keyboard into a server rack. You will manage servers from your couch over the internet using Secure Shell (SSH). SSH creates an encrypted, cryptographic tunnel to the remote server. *Syntax:* ssh [Username]@[IP Address]
bash
1
ssh admin@192.168.1.50

The terminal will ask for a password. Once authenticated, your local terminal prompt will vanish, replaced by the terminal prompt of the remote server. You are now commanding the server from afar!

8. Diagrams/Visual Suggestions

*Visual Concept: The SSH Tunnel* Draw a laptop on the left (Local Machine) and a Server Rack on the right. Draw an open padlock icon. Show a command like rm -rf traveling across the internet in plaintext. Below it, draw a solid, blue pipe connecting the laptop to the server. Label it SSH Port 22. Draw a closed padlock. Show the command rm -rf being transformed into x8f!L9 (encrypted gibberish) inside the pipe, mathematically protecting the command line interface from eavesdroppers.

9. Best Practices

  • Never expose SSH to the public internet on Port 22: Automated hacker bots constantly scan the entire global internet looking for open Port 22s. They will attempt to brute-force guess your root password 50,000 times a second. Always alter your SSH configuration (/etc/ssh/sshd_config) to listen on a random, high port (like Port 2222) to hide from automated attacks.

10. Common Mistakes

  • Forgetting the protocol in wget: Beginners often type wget www.google.com. The command fails. wget is a strict utility; you must provide the absolute Uniform Resource Locator (URL), including the protocol. You must type wget https://www.google.com.

11. Mini Project: The Network Diagnostic Flow

Simulate a troubleshooting scenario:
  1. 1. Confirm you have an IP: Type ip a.
  1. 2. Ensure you can reach the internet: Type ping -c 4 8.8.8.8 (The -c 4 tells Linux to only send 4 pings, just like Windows).
  1. 3. Ensure DNS is working: Type ping -c 4 google.com.
  1. 4. Test HTTP application delivery: Type curl -I https://google.com (The -I flag asks for the HTTP Headers. You should see a "200 OK" response).
You have just performed a full Layer 3 to Layer 7 diagnostic check!

12. Practice Exercises

  1. 1. Contrast the operational use cases of curl and wget. While both interact with web servers, in what specific scenario is wget the superior tool?
  1. 2. Explain the forensic value of the ss -tulpn (or netstat -tulpn) command for a security administrator suspecting a malware infection.

13. MCQs with Answers

Question 1

A system administrator needs to download a .tar.gz installation package directly from a software vendor's website to a remote, headless Linux server. Which command line utility accomplishes this?

Question 2

Which command is used to securely log into the command line interface of a remote Linux server across the internet using encrypted cryptographic keys?

14. Interview Questions

  • Q: A developer complains that their newly deployed Python web application is not reachable over the network. Walk me through the exact CLI commands you would use on the server itself to verify (A) the server has an IP, and (B) the Python app is actively listening on TCP Port 8080.
  • Q: Explain why the legacy telnet protocol was entirely abandoned by the IT industry in favor of the ssh protocol for remote server administration.
  • Q: You attempt to ping a corporate database server and receive 100% packet loss. However, you are still able to successfully ssh into the exact same database server. Explain the network security architecture that causes this behavior.

15. FAQs

Q: I ran curl and my screen filled with a million lines of unreadable code. How do I stop it? A: You likely curled a massive web page or a binary file. Remember your escape hatch! Press Ctrl + C instantly to terminate the running curl process and regain control of your terminal prompt.

16. Summary

In Chapter 10, we expanded our reach beyond the local filesystem into the global network. We verified our local Layer 3 configuration using ip a and diagnosed routing pathways using the classic ping and traceroute sonars. We bridged the gap to the Application Layer, replacing the GUI web browser with the precision of curl for API interactions and wget for direct file downloads. We deployed ss to audit our server's listening ports, acting as an internal security check. Finally, we wielded ssh, the undisputed king of remote management, proving that physical proximity to a server is entirely irrelevant to a modern engineer.

17. Next Chapter Recommendation

Your server is online, but it is empty. You need to install software, web servers, and databases. Proceed to Chapter 11: Package Management in Linux.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·