11 Linux Network Commands: A Terminal Guide

Essential Terminal Commands for Network Management
A wide range of network tasks, from file downloads to network troubleshooting, can be efficiently accomplished using terminal commands.
This compilation presents both established and more recent commands for comprehensive network administration.
Core Network Operations
While graphical user interfaces offer similar functionality, many users – even those primarily using desktop environments – frequently utilize the terminal for tools like ping and other diagnostic utilities.
The command line provides a powerful and direct method for interacting with network settings and data.
Common Use Cases
- File Transfers: Commands facilitate downloading and uploading files directly through the terminal.
- Network Diagnostics: Identify and resolve network connectivity issues with specialized tools.
- Interface Management: Configure and control network interfaces from the command line.
- Statistics Viewing: Access detailed network performance statistics for analysis.
These capabilities make the terminal an indispensable resource for network administrators and power users alike.
Effectively leveraging these commands can significantly streamline network management workflows.
Utilizing curl and wget for File Downloads
Files can be efficiently downloaded from the internet directly within the terminal environment using either the curl or wget commands.
For those employing curl, the command curl -O should be entered, followed by the complete URL path to the desired file.
Alternatively, wget users can simply utilize the wget command itself, without the need for additional options.
Upon execution, the downloaded file will be saved into the user's current working directory.
Command Examples
The following examples illustrate the usage of both commands:
- curl:
curl -O website.com/file - wget:
wget website.com/file
These commands provide a streamlined method for obtaining files directly from the command line, enhancing workflow efficiency.
Ping: A Network Connectivity Tool
The ping utility transmits Internet Control Message Protocol (ICMP) ECHO_REQUEST packets to a designated network address. This functionality allows users to verify network connectivity, determining if communication is possible between a device and a target IP address or internet resource.
It's important to note that some network configurations are set up to ignore or not respond to ICMP Echo Requests, meaning a lack of response doesn't always indicate a connectivity issue.
Behavior Differences Between Operating Systems
The behavior of the ping command differs slightly between operating systems. While the Windows version typically sends a limited number of packets by default, the Linux implementation continues transmitting packets indefinitely until manually stopped.
To limit the number of packets sent in Linux, the -c option can be utilized.
Example Usage in Linux
The following command demonstrates how to send only four ping packets to google.com:
ping -c 4 google.com
This command will send four ECHO_REQUEST packets and then cease transmission, providing a concise assessment of network latency and reachability.
Understanding the ping command is fundamental for basic network troubleshooting and diagnostics.
tracepath & traceroute
The tracepath utility functions in a manner comparable to traceroute, however, it does not necessitate root-level permissions for execution. Notably, it is pre-installed on Ubuntu systems, a distinction from traceroute which is not. Tracepath is designed to map the network route to a designated destination, detailing each “hop” encountered along the way.
Should you experience network difficulties or performance degradation, tracepath can pinpoint the source of the issue, identifying where network failures occur or where slowdowns are present.
tracepath example.com
Understanding the Output
The output from tracepath displays a list of hops. Each hop represents a router or network device between your computer and the final destination. The time taken for each hop is also shown, indicating latency.
Higher latency values at specific hops can suggest potential bottlenecks or areas of network congestion. Analyzing this data helps diagnose network performance issues.
Key Differences from Traceroute
- Privileges: tracepath doesn't require root access, unlike traceroute.
- Default Installation: tracepath is typically included with Ubuntu installations, while traceroute may need to be installed separately.
- Methodology: While both achieve the same goal, they employ different underlying techniques for path discovery.
Traceroute relies on UDP packets, while tracepath uses ICMP packets. This difference impacts how they interact with firewalls and network devices.
In essence, tracepath provides a convenient, user-friendly method for network path analysis without the need for elevated privileges, making it a valuable tool for everyday troubleshooting.
mtr
The mtr utility effectively merges the functionalities of both the ping and tracepath commands into a unified tool.
It operates by consistently transmitting packets and displaying the ping response time for each network “hop” along the route.
This continuous monitoring also reveals potential network issues; for example, a packet loss exceeding 20% at hop 6 can be readily identified.
mtr howtogeek.com
The command provides a dynamic, real-time view of network performance.
To terminate the mtr process, simply press the 'q' key or use the Ctrl-C key combination.
This allows for controlled observation and analysis of network connectivity.
Host Command Functionality
The host utility is a command-line tool used for performing Domain Name System (DNS) lookups. When provided with a domain name, it resolves and displays the corresponding IP address. Conversely, supplying an IP address allows the tool to reveal the associated domain name.
Usage Examples
The following examples demonstrate how the host command can be utilized.
- To find the IP address of a domain:
host howtogeek.com - To find the domain name associated with an IP address:
host 208.43.115.82
These commands provide a quick and efficient method for network troubleshooting and information gathering directly from the Linux terminal.
The host command simplifies the process of understanding the relationship between domain names and IP addresses, which is fundamental to network communication.
It's a valuable tool for system administrators and anyone needing to verify DNS records.

WHOIS Records and Website Ownership
The whois command is a valuable tool for obtaining details regarding a website's registration. It allows users to access records that reveal information about the owner and registrant of a particular domain.
Utilizing the WHOIS Command
To perform a whois lookup, simply use the following syntax in your terminal:
whois example.com
This command will query the whois database and display the associated registration information for the domain 'example.com'.
The information provided by a whois lookup can be crucial for various purposes, including verifying domain ownership and investigating potential misuse.
Understanding how to access and interpret whois records is a fundamental skill for anyone involved in website administration, network security, or domain name management.
ifplugstatus: Network Interface Link Detection
The ifplugstatus utility is designed to determine the connection status of network interfaces, specifically indicating whether a cable is physically connected. It doesn't come pre-installed on Ubuntu systems.
Installation is achieved through the package manager using the following command:
sudo apt-get install ifplugd
Once installed, the command can be executed to check the status of all network interfaces.
ifplugstatus
Alternatively, the status of a particular interface can be queried by specifying its name.
ifplugstatus eth0
The output "Link beat detected" signifies that a network cable is currently plugged into the interface.
Conversely, a status of "unplugged" indicates the absence of a physical connection.
This tool provides a quick and simple method for verifying network cable connectivity directly from the Linux terminal.
ifconfig
The ifconfig command is a powerful tool used for configuring, optimizing, and troubleshooting network interfaces within a system. It provides a rapid method for inspecting IP addresses and other crucial network interface details.
Simply typing ifconfig will display the status of all network interfaces that are currently active, along with their respective names.
Alternatively, you can specify a particular interface name to view information pertaining solely to that interface.
ifconfig
ifconfig eth0
This allows for focused examination of specific network connections.
ifconfig is essential for network administration and diagnostics.
It enables users to quickly assess network connectivity and identify potential issues.
The command’s versatility makes it a cornerstone of Linux network management.
Network Interface Control with ifdown & ifupThe commands ifdown and ifup function analogously to utilizing ifconfig up or ifconfig down. They are employed to deactivate or activate a specified network interface.
Administrative privileges are necessary for their execution, therefore the use of sudo is required on Ubuntu-based systems.
sudo ifdown eth0
sudo ifup eth0
Attempting to run these commands on a typical Linux desktop environment may result in an error. Most desktop Linux distributions leverage NetworkManager to automatically handle network interface management.
NetworkManager Considerations
However, these commands remain functional on server environments where NetworkManager is not implemented.
For command-line configuration of NetworkManager, the nmcli utility should be utilized.
nmcli provides a comprehensive interface for controlling NetworkManager and its associated network connections.
It allows for tasks such as bringing interfaces up or down, modifying connection settings, and displaying network status.
- ifdown deactivates a network interface.
- ifup activates a network interface.
- nmcli is used for NetworkManager control.
Understanding these commands is crucial for network administration in Linux environments, particularly on servers.
While desktop systems often abstract network management, these tools provide direct control when needed.
dhclient
The dhclient utility is employed to request a new IP address from a Dynamic Host Configuration Protocol (DHCP) server, or to relinquish an existing one. Administrative privileges are necessary for its execution, typically achieved using sudo on Ubuntu systems.
Executing dhclient without any specified parameters will initiate a request for a new IP configuration. Conversely, the -r option can be utilized to release the currently assigned IP address.
sudo dhclient -r
sudo dhclient
These commands allow for dynamic network configuration management directly from the Linux terminal.
Releasing and renewing IP addresses can be useful for troubleshooting network connectivity issues or adapting to changes in the network environment.
The dhclient command provides a straightforward method for controlling IP address assignments on a Linux system.
netstat
The netstat utility is capable of displaying a wide range of network interface statistics. This includes information regarding open sockets and routing tables. Executing the netstat command without any specified options will generate a listing of currently open sockets.
However, the functionality of this command extends far beyond this basic operation.
Further Capabilities
For instance, utilizing the netstat -p command allows you to identify the programs that are linked to these open sockets.
Detailed statistics pertaining to all network ports can be accessed through the netstat -s command.
- This provides a comprehensive overview of port activity.
- It's useful for diagnosing network performance issues.
The command offers valuable insights into network connections and their associated processes.
Previously, we have explored commands for both process management and file manipulation.