Innovate | Connect | Transform
ContactService statusUSD $

GICT knowledge base

Common Network Communication Commands in Linux and Their Uses

Published

Linux and Commands

Networking is at the core of what makes Linux so powerful—whether you’re running a web server, automating a deployment, or just browsing the internet. Under the surface, Linux offers a suite of versatile network communication commands that help you diagnose issues, transfer files, monitor connections, and interact with other systems.

These commands aren’t just for system administrators. As a regular user, developer, or hobbyist, you’ll find yourself using them to check connectivity, download files, debug network problems, or even set up secure tunnels. Mastering the essential network communication tools in Linux gives you the confidence and control to handle anything the digital world throws your way.

This guide introduces you to the most common network commands, explains the reasoning behind their usage, and provides plenty of examples and practical scenarios. Whether you’re a beginner or looking to sharpen your skills, you’ll find actionable advice and tips for real-world success.

Prerequisites

Before you start, make sure you have:

  • Access to a Linux system (desktop, server, or virtual machine).
  • Terminal access (local or via SSH).
  • Basic command-line familiarity (running commands, understanding output, using pipes and redirection).
  • Optional: administrative (sudo) privileges for some advanced tasks.

Why Networking Commands Matter

Network communication is at the heart of most modern computing. Servers, clients, cloud services, and local machines all rely on the ability to send and receive data. When something goes wrong—or when you need to automate a process—Linux’s network commands let you take direct control, spot issues, and keep things running smoothly.

Having a toolkit of commands means you can:

  • Test if a server or service is reachable.
  • Diagnose slow or failed connections.
  • Transfer files securely and efficiently.
  • Monitor bandwidth and network activity.
  • Troubleshoot DNS or routing problems.
  • Securely connect to remote systems.

Essential Network Communication Commands

1. ping — Test Connectivity

Purpose:

Check if another computer or server is reachable and measure response time.

Usage:

ping example.com

How it works:

ping sends small packets (ICMP echo requests) to the target host. If the target is reachable, it replies. The command shows how long each packet takes to travel back and forth.

Example output:

PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34: icmp_seq=1 ttl=56 time=12.3 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=56 time=12.2 ms

Common options:

  • -c 4: Send only 4 packets, then stop. ping -c 4 google.com
  • -i 2: Wait 2 seconds between pings.

Real-world use:

Use ping to check if your server is online, test your internet connection, or measure network latency. If you get “Destination Host Unreachable” or “Request timed out,” there’s probably a network issue between you and the target.

2. ifconfig / ip — View and Configure Network Interfaces

ifconfig (Older, but still common)

ifconfig

Shows your network interfaces, their IP addresses, MAC addresses, and statistics.

ip (Modern replacement)

ip addr

Lists all IP addresses assigned to network interfaces.

ip link

Shows interface state (up or down), MAC addresses, and more.

Example output:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:98:6b:7d brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic eth0

Common tasks:

  • Check your IP address: ip addr show eth0
  • Bring an interface up or down: sudo ip link set eth0 up / sudo ip link set eth0 down

Real-world use:

If you’re troubleshooting why your server isn’t connecting to the network, these commands help you spot problems with IP addresses, interface status, or physical connections.

3. hostname — Show or Set System Hostname

Usage:

hostname

Displays your computer’s network name.

To temporarily set a new hostname:

sudo hostname newname

To permanently change it, edit /etc/hostname and (if needed) /etc/hosts.

Real-world use:

Hostnames matter for networking, especially in environments with multiple computers. They help identify machines on a local network or in the cloud.

4. nslookup / dig / host — Query DNS Records

nslookup

nslookup www.google.com

Shows the resolved IP address and DNS server used.

dig (more detailed)

dig www.google.com

Returns detailed DNS query results, including all associated IPs, TTL, and server response time.

host

host www.google.com

Simple DNS lookup, often faster for quick checks.

Real-world use:

These commands help you troubleshoot DNS issues, verify if a website’s address resolves correctly, or check which IPs are assigned to a domain.

5. traceroute — Trace the Path to a Host

Usage:

traceroute example.com

Shows the route that packets take to reach the target, listing each server (hop) along the way and the delay at each step.

Common options:

  • -n: Show IP addresses only (faster).
  • -m 15: Limit to 15 hops.

Example output:

1  192.168.1.1  1.123 ms  1.245 ms  1.085 ms
2  10.0.0.1     2.134 ms  2.118 ms  2.102 ms
3  203.0.113.1  12.345 ms  12.321 ms  12.311 ms

Real-world use:

If a website or server is slow or unreachable, traceroute helps you pinpoint where the problem occurs—at your router, your ISP, or further down the line.

6. netstat / ss — Network Connections and Statistics

netstat (older, still widely used)

netstat -tulnp

Lists all listening ports and the associated processes:

  • -t: TCP
  • -u: UDP
  • -l: Listening
  • -n: Show numerical addresses
  • -p: Show process ID/program name

ss (modern replacement)

ss -tulnp

Example output:

tcp  LISTEN 0      128         0.0.0.0:22      0.0.0.0:*     users:(("sshd",pid=1234,fd=3))

Real-world use:

Check which ports are open, which services are listening, and whether an application is actually using the expected port.

7. curl and wget — Download and Interact with Web Resources

curl

curl https://www.example.com

Fetches the content of a web page or API endpoint.

Download a file:

curl -O https://example.com/file.zip

Send data to a server (POST request):

curl -d "key=value" -X POST https://example.com/api/

wget

wget https://example.com/file.zip

A simpler, robust downloader for files, recursive downloads, and even mirroring entire sites.

Real-world use:

Use these commands to quickly fetch files, test APIs, automate software downloads, or script updates without a web browser.

8. scp and rsync — Secure File Transfer

scp — Secure Copy over SSH

Copy a file to a remote machine:

scp localfile.txt user@remote:/home/user/

Copy a directory recursively:

scp -r folder/ user@remote:/home/user/

rsync — Efficient File Synchronization

Sync a local folder with a remote server:

rsync -avz myfolder/ user@remote:/home/user/myfolder/
  • -a: Archive (preserves permissions, etc.)
  • -v: Verbose
  • -z: Compress during transfer

Real-world use:

Great for backups, website deployments, and keeping folders in sync across computers. rsync only sends changed files, making it fast and efficient.

9. ftp / sftp — File Transfer Protocols

ftp (not encrypted, use only on trusted networks)

ftp ftp.example.com

Legacy tool for logging into FTP servers to upload/download files.

sftp (secure, uses SSH)

sftp user@remote

An interactive session for secure file transfer—navigate directories, upload, and download files.

10. telnet and nc (netcat) — Test Open Ports and Services

telnet

telnet example.com 80

Opens a connection to port 80 on example.com, letting you test if a service is reachable and manually interact with it.

nc (netcat)

nc -vz example.com 443

Checks if port 443 is open (useful for testing HTTPS, SSH, or any custom service).

Real-world use:

Great for troubleshooting whether a service is running, a firewall is blocking a port, or if you can reach an external server.

11. route and ip route — View and Manage Routing Tables

View routing table:

route -n

or

ip route

Shows which gateways your system uses to reach different networks.

Add a route (advanced):

sudo ip route add 10.1.0.0/16 via 192.168.1.1

Real-world use:

When you’re setting up VPNs, troubleshooting multi-network setups, or diagnosing routing issues.

12. arp — Address Resolution Protocol Table

arp -a

Shows the mapping of IP addresses to MAC (hardware) addresses on your local network.

Real-world use:

Useful for troubleshooting LAN connectivity and seeing which devices your computer has communicated with.

13. lsof — List Open Files and Ports

sudo lsof -i :80

Shows which process is using port 80.

14. iwconfig and nmcli — Wireless Networking

iwconfig

iwconfig

Displays wireless network interfaces and their status.

nmcli (Network Manager CLI)

nmcli device wifi list

nmcli device wifi connect "SSID" password "yourpassword"

Real-world use:

Manage Wi-Fi connections directly from the terminal—handy for headless systems or remote troubleshooting.

Combining Commands and Scripting

The real power of Linux networking tools is that you can chain them with pipes (|) and use them in scripts.

Check if a web server is up and send an alert if it’s not:

if ! curl -s --head https://example.com | grep "200 OK" > /dev/null
then
    echo "Website is down!" | mail -s "Alert" [email protected]
fi

Monitor bandwidth usage (install iftop or bmon):

sudo apt install iftop
sudo iftop

Practical Scenarios

Scenario 1: Diagnosing a Connection Issue

Suppose you can’t reach your company’s web server:

ping yourserver.com
dig yourserver.com
traceroute yourserver.com
nc -vz yourserver.com 443
ip addr

Scenario 2: Securely Copy Files to a Remote Server

You’ve finished a project and want to back it up to a remote server.

scp -r ~/Projects/myproject user@backup:/home/user/backups/

For regular backups, switch to rsync for speed and reliability.

Scenario 3: Monitor Server Open Ports

You want to see what services are running on your server:

ss -tulnp

or

netstat -tulnp

You spot unnecessary open ports and shut down the corresponding services for better security.

Scenario 4: Test an API Endpoint

You’re developing a web app and want to see if your API is responding:

curl -i https://api.yoursite.com/v1/status

The -i flag includes HTTP headers in the output.

Avoiding Common Pitfalls

  • Remember that some commands (like ping or traceroute) can be blocked by firewalls or network policies.
  • Use sudo only when necessary and understand the risks—especially when managing routes or network interfaces.
  • Double-check addresses and command options before transferring files, to avoid overwriting or deleting important data.
  • Always test scripts and command combinations in a safe environment before deploying to production systems.

Building Productive Habits

  • Keep a cheatsheet of your most-used network commands.
  • Use pipes and redirection to filter, log, or analyze output as needed.
  • Script routine checks (like server health or bandwidth usage) to save time.
  • Stay updated on modern tools (like ip over ifconfig, ss over netstat) for better performance and features.
  • Practice troubleshooting with real scenarios—nothing beats hands-on experience.

Conclusion

Network communication is foundational to every modern Linux system. Whether you’re checking connectivity, transferring files, diagnosing issues, or managing configurations, these commands are your essential toolkit. Understanding how and when to use tools like ping, ip, curl, scp, and ss allows you to solve problems quickly, keep systems secure, and automate your workflow.

Don’t just memorize commands—experiment with them. Try out different options, chain them together, and integrate them into scripts. The more you use these tools, the more comfortable and powerful you become as a Linux user.

With practice, you’ll handle networking challenges with confidence, whether you’re working on a personal project, supporting a team, or managing critical infrastructure. Networking is no longer a black box—it’s a set of levers and dials you can control directly from your terminal.

Related guides

Account services are unavailable until the production backend is configured.