In this chapter, we’ll explore linux networking basics using command line. You’ll learn how to use commands like ping, curl, ifconfig and others to interact with networks, troubleshoot connectivity, and transfer data. By the end of this chapter, you’ll be able to diagnose network issues, download files, and configure basic network settings.

Summary

This guide covers essential Linux networking tools for Debian 12, from basic commands like ping and wget to advanced tools like nmap and tcpdump. Practice these to build a solid networking foundation.

Linux Networking Basics

Linux networking basics equips you with essential skills to manage and troubleshoot networks on Debian 12. Learn to use commands like ping, curl, ssh, and ip to check connectivity, transfer data, secure remote access, and monitor network activity, ideal for beginners handling everyday tasks like browsing, file sharing, or remote work.

Note: Most tools are pre-installed on Debian. Install others with apt (see Chapter 15).

Why Learn Linux Networking Basics?

Networking is vital for connecting devices, accessing online resources, and managing remote systems. Mastering Linux networking basics empowers you to troubleshoot connectivity, secure data transfers, and optimize network settings, whether you’re a home user, student, or small office worker.

Basic Networking Commands

ping: Test Connectivity

Sends ICMP requests to check if a host is reachable.

Advanced Usage:

Alternatives:

curl: Transfer Data

Fetches or sends data via protocols like HTTP/HTTPS/FTP. For detailed usage, see the section below.

wget: Download Files

Downloads files from the web, supporting recursive downloads. For detailed usage, see the section below.

dig: DNS Lookup

Queries DNS servers for domain information.

$ sudo apt install dnsutils
$ dig google.com

Advanced Usage:

Alternatives:

whois: Domain/IP Information

Retrieves registration details from the WHOIS database.

Advanced Usage:

Alternatives:

Network Configuration

ip: Manage Interfaces

Displays and configures network interfaces.

$ ip addr

nmcli: NetworkManager CLI

Manages network connections via NetworkManager.

$ nmcli con show

Network Diagnostics

ss: Socket Statistics

Shows socket and connection details.

$ ss -tuln

traceroute: Trace Packet Path

Traces the route packets take to a destination.

$ traceroute google.com

mtr: Real-Time Diagnostics

Combines ping and traceroute for live network analysis.

$ sudo apt install mtr
$ mtr google.com

Advanced Usage:

Alternatives:

nload: Bandwidth Monitoring

Monitors network bandwidth usage in real time.

$ sudo apt install nload
$ nload

Secure Networking

ssh: Remote Access

Securely connects to remote systems.

$ ssh user@remote_host

scp: Secure File Transfer

Transfers files securely between hosts.

$ scp file.txt user@remote_host:/path/

Advanced Networking Tools

nmap: Network Scanning

Scans networks for hosts and services.

$ sudo apt install nmap
$ nmap 192.168.1.0/24

tcpdump: Packet Capture

Captures and analyzes network packets.

$ sudo tcpdump -i eth0

httpie: User-Friendly HTTP Client

Simplifies HTTP requests with a user-friendly interface.

$ sudo apt install httpie
$ http GET https://api.example.com

Practical Examples

Test connectivity: ping -c 10 google.com

Download a webpage: wget https://example.com

Check DNS: dig +short google.com

Practice Time!

Glossary of Commands, Tools, and Shortcuts

Command/Tool Description
ping Tests network connectivity.
curl Transfers data via various protocols.
wget Downloads files from the web.
dig Performs DNS lookups.
whois Retrieves domain/IP registration info.
ip Manages network interfaces.
nmcli Controls NetworkManager.
ss Displays socket statistics.
traceroute Traces packet paths.
mtr Real-time network diagnostics.
nload Monitors bandwidth usage.
ssh Secure remote access.
scp Secure file transfer.
nmap Network scanning.
tcpdump Captures network packets.
httpie User-friendly HTTP client.
Penguins networking at a snowman themed event. Linux Networking basics
Penguins networking at a snowman themed event. AI generated image (grok)

Detailed Note: Wget and Curl

Wget

wget is a command-line tool used to download files from the internet. It supports HTTP, HTTPS, and FTP protocols, and can be used to download files from websites, FTP servers, and other online sources.

Typical Use Cases:

Example Usage:

$ wget https://example.com/file.txt

This will download the file file.txt from the website https://example.com and save it to your current directory.

Advanced Use Cases:

Curl

curl is a command-line tool used to transfer data to and from a web server using HTTP, HTTPS, SCP, SFTP, TFTP, and other protocols. It can be used to download files, upload files, and send HTTP requests.

Typical Use Cases:

Example Usage:

$ curl https://example.com/file.txt -o file.txt

This will download the file file.txt from the website https://example.com and save it to your current directory.

Advanced Use Cases:

Alternatives

Wget Alternatives:

Curl Alternatives:

Differences Between Curl, Wget, and Command-Line FTP Tools

curl excels in flexibility, supporting numerous protocols and data transfers, while wget is optimized for downloading with features like recursion. Command-line FTP tools like ftp or lftp focus on FTP-specific tasks, lacking the broad protocol support of curl or the simplicity of wget.

Penguin showing two cards- wget and curl, Linux Networking basics
Linux Networking basics AI generated Image

That’s it for Chapter 17 , Linux Networking Basics ! You’ve now learned how to use networking commands to diagnose issues, transfer data, and configure network settings. In the next chapter, we’ll dive into compiling programs—how to build software from source code. Until then, practice these commands to become more comfortable with networking in Linux.

Previous: Chapter 16 | Next: Part III