Understanding networking commands in Ubuntu and Linux is important for anyone looking to manage or troubleshoot their systems effectively.
Whether you’re a beginner or an experienced user, mastering these commands can enhance your ability to configure network settings, monitor connectivity, and diagnose issues with ease.
This post will explore the top networking commands you should know, providing clear explanations and examples to help you navigate the command line confidently.
If you need more help or want to give us feedback, please leave a comment below or contact us.
Top Ubuntu Network Commands with Examples
1. ping
ping
is your go-to command for checking if a network connection is alive and responding. It’s simple but incredibly powerful for diagnosing connectivity issues, making it a must-have tool for any Linux user dealing with networks.
Syntax:
ping [options] destination
Example:
ping google.com
This command checks if google.com
is reachable and measures how long it takes for packets to travel back and forth.
2. ifconfig
Although it’s slowly being replaced by ip
, ifconfig
remains a classic command for configuring and viewing your network interfaces. It’s like a snapshot of your network setup, making it perfect for troubleshooting IP configuration issues.
Syntax:
ifconfig [interface] [options]
Example:
ifconfig eth0
This shows details of the eth0
interface, such as its IP address and MAC address.
3. ip
ip
is the modern, powerful replacement for ifconfig
. It’s packed with features to handle everything from displaying IP addresses to configuring routing. If you’re working with newer Linux distributions, this is your go-to tool.
Syntax:
ip [options] object {command}
Example:
ip addr show
This displays all network interfaces and their IP addresses on your system.
4. netstat
netstat
is like a Swiss Army knife for monitoring network connections. Whether you’re diagnosing server issues or spotting unauthorized connections, it’s a critical tool to have in your arsenal.
Syntax:
netstat [options]
Example:
netstat -tuln
This lists all active listening ports (TCP/UDP), helping you see what services are running on your system.
5. traceroute
When your packets feel lost, traceroute
is here to help. This command maps out the path your data takes to reach its destination. It’s invaluable for identifying network bottlenecks or slow hops along the route.
Syntax:
traceroute [destination]
Example:
traceroute google.com
This shows the network path from your system to google.com
, hop by hop.
6. curl
curl
is the command-line equivalent of a browser. It lets you transfer data from a URL and is essential for testing APIs, downloading files, or debugging web requests. Developers and sysadmins love it for its flexibility.
Syntax:
curl [options] URL
Example:
curl https://www.example.com
This retrieves the content of https://www.example.com
.
7. wget
If you need to download files in bulk or automate fetching resources, wget
is your tool. Unlike curl
, it’s specialized for file downloads, making it perfect for grabbing website content or backup scripts.
Syntax:
wget [options] URL
Example:
wget https://www.example.com/file.zip
This downloads the file located at the specified URL.
8. nslookup
Ever wonder what IP address is behind a domain name? That’s where nslookup
shines. It’s a quick way to resolve domain names to IPs, making it essential for DNS troubleshooting.
Syntax:
nslookup [hostname]
Example:
nslookup google.com
This retrieves the IP address associated with google.com
.
9. dig
If you need more detailed DNS information than nslookup
, dig
is your best friend. From finding DNS records to debugging name servers, this command is a favorite of network engineers.
Syntax:
dig [options] [domain]
Example:
dig google.com
This fetches detailed DNS records for google.com
.
10. arp
Want to see which devices are connected to your network? arp
gives you a peek into the Address Resolution Protocol table, helping you match IP addresses to MAC addresses.
Syntax:
arp [options]
Example:
arp -a
This lists all ARP entries, showing devices currently communicating with your machine.
11. nmap
nmap
is the king of network scanning tools. Whether you’re mapping a network, auditing security, or discovering open ports, nmap
is a must-have command for admins and pentesters alike.
Syntax:
nmap [options] [target]
Example:
nmap 192.168.1.1
This scans the target IP address for open ports and active services.
12. ss
If you love netstat
, you’ll appreciate ss
. It’s a faster, more modern tool for displaying network sockets and active connections.
Syntax:
ss [options]
Example:
ss -tuln
This lists all listening TCP and UDP connections in numeric format.
13. ethtool
Need to check or tweak your Ethernet card’s settings? ethtool
has you covered. It’s ideal for troubleshooting hardware or optimizing network performance.
Syntax:
ethtool [options] [interface]
Example:
ethtool eth0
This shows the capabilities and status of the eth0
Ethernet interface.
14. tcpdump
For deep packet inspection and network analysis, tcpdump
is your command of choice. It’s a favorite of network admins for diagnosing low-level network issues.
Syntax:
tcpdump [options]
Example:
tcpdump -i eth0
This captures all network traffic on the eth0
interface.
15. whois
Curious about who owns a domain? whois
provides registration details, making it useful for security research or domain management.
Syntax:
whois [domain]
Example:
whois google.com
This retrieves information about the google.com
domain.
16. iftop
Need a real-time view of bandwidth usage? iftop
visualizes the data flowing in and out of your network interfaces, making it great for spotting bandwidth hogs.
Syntax:
iftop [options]
Example:
iftop -i eth0
This monitors traffic on the eth0
interface.
17. iptraf
For an interactive way to monitor network traffic, iptraf
provides a real-time view of packets and bandwidth on your interfaces.
Syntax:
iptraf [options]
Example:
iptraf-ng
This launches the interactive network monitor.
18. route
Ever wonder how your data knows where to go? route
shows your system’s routing table, which is key for diagnosing gateway and routing issues.
Syntax:
route [options]
Example:
route -n
This displays the routing table in numeric format.
19. scp
Securely transfer files between systems using scp
. It’s built on SSH, so your data is encrypted during transfer, making it perfect for remote file management.
Syntax:
scp [source] [destination]
Example:
scp file.txt [email protected]:/home/user/
This copies file.txt
to the remote server.
20. iptables
iptables
is your tool for managing firewall rules on Linux. If you need to block traffic, allow specific IPs, or secure your server, iptables
is important, very.
Syntax:
iptables [options]
Example:
iptables -L
This lists all active firewall rules on your system.
Want more? Check out our Top Ubuntu Commands.