Linux powers servers, cloud infrastructure, and development environments across the world.
Whether you’re debugging connectivity or exploring network performance, knowing the right commands can save hours of troubleshooting.
Here are 10 essential Linux network commands every developer and sysadmin should know — what they do, when to use them, and example syntax.
1. ifconfig — Configure and View Network Interfaces
ifconfig (interface configurator) displays or configures network interfaces.
You can use it to assign IP addresses, enable or disable interfaces, or view network details.
Syntax:
ifconfig
Example use cases:
- Check all active interfaces
- Set a new IP address
- Enable or disable an interface
2. traceroute — Trace the Path to a Destination
traceroute helps troubleshoot network routes and latency by tracking packets from your system to a destination host. It lists each hop along the way, showing where delays occur.
Syntax:
traceroute <destination>
Example:
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
traceroute google.com
Quick tips:
- Install it if missing:
sudo apt-get install inetutils-traceroute - Skip reverse DNS lookup for faster results:
traceroute -n google.com - Each in the output may indicate packet loss or unreachable hops.
3. tracepath — Trace Without Root Access
tracepath is a simpler, non-privileged alternative to traceroute.
It traces the route to a destination and highlights where delays or weak network links occur.
Syntax:
tracepath <destination>
Example:
tracepath google.com
Why use it?
- Doesn’t require
sudo - Installed by default on most Linux distros
4. ping — Test Network Connectivity
The ping command checks whether a host is reachable and measures the round-trip time for packets.
It keeps sending ICMP echo requests until you stop it.
Syntax:
ping <destination>
Example:
ping google.com
To send a specific number of packets:
ping -c 5 google.com
Press Ctrl + C to stop execution.
5. netstat — Network Statistics and Connections
netstat displays network connections, routing tables, and interface statistics. It’s a powerful tool for understanding what’s happening under the hood.
Syntax:
netstat
Common variations:
- Show active programs:
netstat -p - Display detailed port statistics:
netstat -s - Show the routing table:
netstat -r
Example output:
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp4 0 0 1.2.3.4:5865 4.3.2.1:https ESTABLISHED
6. hostname — View or Change System Name
hostname displays or sets the name of your machine on the network.
Syntax:
hostname
Set a temporary hostname:
sudo hostname <newName>
To set it permanently:
- On Ubuntu: edit
/etc/hostname - On RHEL: edit
/etc/sysconfig/network
After editing, reboot your system.
7. curl — Transfer Data from URLs
curl transfers data from or to a server using various protocols (HTTP, HTTPS, FTP).
It’s often used for API testing or downloading files.
Syntax:
curl -O <URL>
Example:
curl -O <https://example.com/file.zip>
Use it with flags to customize requests, test APIs, or send data.
8. wget — Download Files from the Web
wget is a command-line downloader that supports HTTP, HTTPS, and FTP.
It can resume downloads, work in the background, and even mirror entire websites.
Syntax:
wget [options] [URL]
Examples:
- Download a file:
wget <http://example.com/sample.html> - Resume a download:
wget -c <http://example.com/samplefile.tar.gz> - Download in the background:
wget -b <http://example.com/sample.html>
9. whois — Lookup Domain Information
whois fetches domain registration data, including ownership, registrar, and expiry information.
Syntax:
whois <domain>
Example:
whois google.com
Useful for verifying domain owners or checking registration details.
10. scp — Securely Copy Files Between Systems
scp (Secure Copy) transfers files securely between local and remote systems using SSH encryption.
Syntax:
scp [options] user@src_host:file user@dest_host:file
Examples:
- Copy from local to remote:
scp file.txt [email protected]:/home/user/ - Copy from remote to local:
scp [email protected]:/home/user/file.txt . - Copy directories recursively:
scp -r folder/ [email protected]:/home/user/
Common options:
i→ use a specific SSH keyr→ copy directories recursively
11. ssh — Securely Connect to Remote Systems
ssh (Secure Shell) is used to log into remote servers securely over an encrypted connection.
Syntax:
ssh username@host
Example:
ssh -i ~/key.pem [email protected]
Default port: 22
SSH encrypts both commands and responses, keeping your data secure.
Final Thoughts
Mastering these network commands can dramatically improve your efficiency when diagnosing issues, monitoring connections, or managing remote systems.
Once you’re comfortable with these basics, tools like ss, ip, and nmap can take your Linux networking skills even further.
