Essential Networking Commands in Linux: Monitor, Troubleshoot, and Transfer Data Like a Pro
Networking is at the heart of modern computing. Whether you’re managing servers, developing web apps, or simply troubleshooting internet issues, understanding Linux networking commands is crucial. The terminal provides powerful tools to help you diagnose connectivity problems, monitor network traffic, transfer files securely, and interact with remote servers.
In this comprehensive guide, youโll learn how to use key networking commands like ifconfig
, ip
, ping
, netstat
, ssh
, scp
, curl
, and more. Plus, youโll see real-world examples that can be easily integrated into your workflows or shell scripts.
Why Learn Networking Commands in Linux?
Linux is widely used in server environments where graphical network tools donโt exist. Knowing how to work with the command line allows you to:
-
Diagnose and fix connectivity issues
-
Securely access and manage remote systems
-
Automate file transfers and data fetching
-
Test server availability and API endpoints
Letโs dive into the essential commands you need to master.
๐ Viewing Network Configuration
๐ง ifconfig
(or ip a
)
ifconfig
is the classic tool to check your network interfaces, though newer systems prefer ip
.
๐น Check IP Address and Interfaces:
ifconfig
Or with ip
:
ip a
Youโll see all available interfaces (like eth0
, wlan0
, lo
) and their IPs, MAC addresses, and states.
๐น Bring an Interface Up or Down:
sudo ifconfig eth0 up
sudo ifconfig eth0 down
Or using ip
:
sudo ip link set eth0 up
Use this when configuring or troubleshooting NICs (Network Interface Cards).
๐ถ Testing Connectivity with ping
The ping
command checks if a host is reachable over the network and measures latency.
๐น Basic Usage:
ping google.com
๐น Limit the Number of Pings:
ping -c 4 example.com
This is a quick way to test DNS resolution and whether your system can access the internet or another host on the network.
๐ก Monitoring Ports and Connections with netstat
or ss
๐ ๏ธ netstat
(deprecated in many distros)
Shows active connections, listening ports, and routing tables.
๐น List All Connections:
netstat -tulnp
-
t
= TCP -
u
= UDP -
l
= Listening -
n
= Numeric IPs -
p
= Show processes
โก ss
โ Faster, Modern Alternative
ss -tulwn
ss
is more lightweight and recommended for modern systems.
๐ Interacting with Web Resources: curl
and wget
๐ curl
โ Client URL
Fetch content from URLs and interact with APIs.
๐น Get Webpage HTML:
curl https://example.com
๐น Test API Endpoint:
curl -X GET https://api.example.com/data
You can also use curl
in scripts for automation, authentication, and more.
๐ฅ wget
โ Download Files
Simple and powerful for downloading files from the web.
wget https://example.com/file.zip
Supports HTTP, HTTPS, and FTP protocols. Great for automated downloads.
๐ Secure Remote Access: ssh
, scp
, sftp
๐ ssh
โ Secure Shell
Log into remote systems securely.
ssh user@remote_host
You can also run commands remotely:
ssh user@server "df -h"
๐ scp
โ Secure Copy
Transfer files between local and remote systems.
scp file.txt user@remote_host:/path/to/destination/
To copy a folder:
scp -r folder/ user@remote_host:/backup/
๐ sftp
โ Secure FTP Interface
Interactive file transfer similar to FTP but over SSH.
sftp user@remote_host
Once connected:
cd /remote/dir
put localfile.txt
get remotefile.txt
Real-World Use Cases
โ
1. Troubleshoot Internet Connectivity
ping 8.8.8.8
ip a
โ
2. Check Whatโs Using Port 80
ss -tuln | grep :80
โ
3. Download Software or Data for a Script
wget https://example.com/data.csv -O data.csv
โ
4. Securely Back Up a File to a Remote Server
scp /var/log/syslog user@backup-server:/logs/
โ
5. Automate API Calls in Shell Scripts
curl -s https://api.exchangerate-api.com/v4/latest/USD > usd_rates.json
Whatโs Next?
Now that you know how to monitor your network, test connectivity, fetch data, and transfer files securely, itโs time to ensure your system is equipped with the tools you need.
In our next blog post, weโll explore:
-
Package management with
apt
,yum
, anddnf
-
Installing new networking tools and utilities
-
Updating your system and keeping it secure
Want to extend your system with powerful tools and stay up-to-date? Linux package management and system updates!