Computers are often connected to each other through a network and communicate by sending data in the form of packets from a source host to a destination. Linux provides a wide range of commands that help users configure networks, test connectivity, and troubleshoot network-related issues. This article explains some of the most commonly used Linux networking commands with their purpose and usage.
Using Ping (Packet Internet Groper)Â Command
The ping command is used to ensure that a computer can communicate with a specified device over the network. The pings command sends Internet Control Message Protocol (ICMP) Echo Request messages in the form of packets to the destination computer and waits in order to get the response back. Once the packets are received by the destined computer, it starts sending the packets back. This command keeps executing until it is interrupted.Â
ping command provides details such asÂ
- the number of packets transmitted.
- the number of packets received.
- time is taken by the packet to return.
ping command is generally used for the following purposes:
- measuring the time taken by the packets to return to determine the speed of the connection.
- to make sure that the network connection between the host and the destined computer can be established.


Using nslookup Command
The nslookup command is used to query DNS (Domain Name System) records. It helps retrieve the IP address of a domain name or the domain name associated with an IP address. This command is commonly used for DNS troubleshooting.

Using traceroute Command
The traceroute command is used to determine the path taken by packets from the source to the destination host. It also shows the number of hops required to reach the destination.
The output displays a list of intermediate routers through which the packet travels, helping identify network delays or failures.

Using host Command
The host command is used to perform DNS lookups. It can find:
- The IP address associated with a domain name
- The domain name associated with an IP address
The returned IP address may be IPv4 or IPv6.


Using netstat Command
The netstat (Network Statistics) command displays information about:
- Network connections
- Routing tables
- Interface statistics
- Port status
This command works with the Linux networking subsystem and primarily displays information from the /proc/net directory.


Using Arp Command
The ARP (Address Resolution Protocol) command is used to display and modify ARP cache, which contains the mapping of IP address to MAC address. The system's TCP/IP stack uses ARP in order to determine the MAC address associated with an IP address.Â


Using ifconfig Command
The ifconfig (Interface Configuration) command is used to display or configure network interfaces. It can:
- Assign IP addresses
- Configure netmasks
- Enable or disable interfaces
- Display MTU (Maximum Transmission Unit) values
Many Unix-like systems use ifconfig during boot to initialize network interfaces.

Using Dig Command
The Dig Command is called domain information groper; it is a tool used to find query information related to domain name and troubleshoot DNS issue in Linux. This tool can provide various types of DNS records, such as CNAME, MX records and records etc.Â
For example: If we want to query a record for "google.com"
Syntax:
dig A google.com

This will show the IP address associated with the domain name.
Using Route Command
The Route Command tool helps us display and manipulate the routing table in Linux. Information contained by this is about how network packets should be routed through a network.
Syntax:
route

This command shows destination, mask, flags, metric, gateway, reference count, and interface. We can also add or delete routes from a network with IP address.
For example: If we have "IP address: 192.168.90.0" and "Subnet mask = 24" and "gateway (gw) = 10.0.0.1"
Syntax:
route add -net 192.168.90.0/24 gw 10.0.0.1
Using Ethtool Command
The ethtool command is used to view and modify network interface card (NIC) settings. It has replaced the older mii-tool.
It can display:
- Link speed
- Duplex mode
- Auto-negotiation status
Example:
To view settings of the interface enp0s3:
enthool enp0s3
You can find your NIC name by using "ifconfig" command.

Using Hostname Command
The Hostname command is used to display the current hostname of the system.

We can also change our host name by using commands.
syntax:
hostnamectl set-hostname mypc
This will set the hostname to "mypc" and display it after reboot also.

