Table of contents
1.
Introduction
2.
Network Commands in Linux
2.1.
ip
2.2.
ifconfig
2.3.
ping
2.4.
tracepath
2.5.
ss
2.6.
traceroute
2.7.
netstat
2.8.
dig
2.9.
host
2.10.
nslookup
2.11.
iwconfig
2.12.
ifplugstatus
2.13.
mtr
2.14.
arp
2.15.
route
2.16.
whois
2.17.
nmap
2.18.
iperf
3.
Frequently Asked Questions
3.1.
Why do we use network commands?
3.2.
What are the types of network interfaces in Linux?
3.3.
Why do we use netstat command in Linux?
3.4.
Why does networking utilize Linux?
3.5.
Where can we find ipconfig in Linux?
4.
Conclusion
Last Updated: Mar 27, 2024

Linux - Network Commands

Author Aditya Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

As we know to make a connection between two or more computers, we use networking, and for networking, there are some commands to make the connection faster rather than doing manually. 

Networks can be in any range in size, from two connected computers at home to a huge enterprise or the Internet, which connects systems worldwide. The networking tools available and managed by the Linux operating system are quite powerful and include routing, bridging, virtual networks, and monitoring. 

network commands

This article will discuss all the network commands available in Linux and how we can use them. Let's discuss network commands in Linux, which are available.

Network Commands in Linux

If we talk about linking computers, whether used for internal or external information sharing, every computer is linked to another computer over a network. A tiny network, such as a few computers connected in your house or school, or a huge, complex network, such as a large university or the entire Internet, might be considered a network.

A system/network administrator's responsibility is maintaining a system's network. Troubleshooting the network and network configuration are two of their main responsibilities.

Here is a list of commands for networking and troubleshooting:

ip

The more recent ifconfig command is the Linux ip command. It is a useful tool for Linux administrators to configure network interfaces. It can assign and delete addresses, raise or lower interfaces, and perform many other helpful operations.

Here are some operations of it in Linux machine.

ip

ifconfig

ifconfig network command in Linux means Interface Configurator. We can start an interface, assign an IP address, and activate or disable an interface using this command. Route and network interface are displayed by using ifconfig.

With the ifconfig command, you may view your IP address, MAC address, and MTU (Maximum Transmission Unit). ip command is a modern variation of ifconfig. The ifconfig command is functional for all versions.

Here is the implementation of it in a Linux machine.

ifconfig

ping

Acronym for the Linux ping command (Packet Internet Groper). If a server is available, it determines whether there is communication between two nodes. The data is displayed on the response from the remote server after sending ICMP ECHO_REQUEST packets to network hosts. 

It determines if a distant host is online or whether network interfaces may be accessed. Additionally, it is used to determine whether a network connection between two devices is available. You can use it to check your network connection and confirm any network problems.
 

Until you pause it, the ping command continues to run and send the packet. By pressing CTRL and C, you can halt the execution. Lets try to ping codingninjas.com, here is the implementation of it.

ping

tracepath

It needs to be installed in Linux. It follows the specified destination's network path and logs each hop in the process. If your network is slow, tracepath will show you where your network is vulnerable. We will be tracing the path of codingninjas.com here is the implementation of it.

tracepath

ss

The netstat network command has been replaced by the ss command. Compared to netstat, this command provides more information. Given that it receives all of its data from kernel userspace, it is also quicker than netstat. Here are some operations of the ss command in Linux with its implementation.

ss
ss

traceroute

It is already installed in Linux. The Linux traceroute network command is a network debugging tool that enables us to figure out how many hops and packets must travel before reaching a destination. It is used to show how data is transferred between a local and a remote workstation. One of the typical examples of the traceroute is loading a website. 

When a web page loads, data is transferred via a network and routers. The traceroute tool can show a network's routers' routes, IP addresses, and hostnames. It may be helpful for figuring out network problems. We will be tracing the route of codingninjas.com here is the implementation of it.

traceroute

netstat

netstat means Network statistics. Open sockets, routing tables, and connection data are only a few of the interface characteristics that are displayed. Additionally, it can be used to show all of the socket connections (including TCP, UDP). In addition to showing connected sockets, it also shows sockets that are waiting to be attached. It is a useful tool for system and network administrators. Here is the implementation of netstat.

netstat

dig

dig means Domain Information Groper. To query DNS name servers for tasks involving DNS lookup, use this command. It mostly focuses on fixing DNS-related issues. It is a versatile tool for investigating DNS (Domain Name Servers). It is used to carry out DNS lookups and retrieve the name server's requested responses. Most DNS administrators typically use it to investigate DNS issues. It is an easy-to-use tool that produces a transparent result. Here is the implementation of dig network command in Linux.

dig

host

The domain name for a given IP address is displayed by the Linux host command, or vice versa. In connection with the DNS query, it also conducts DNS lookups. The host command's default behavior shows a list of the command-line parameters and the arguments it supports. We will be using the codingninjas.com host to get its IP address. Here is the implementation of it.

host

nslookup

nslookup network command in Linux is used to find the Domain Name System(DNS) related query. We will be using codingninjas.com to look up the DNS query. Here is the implementation of it.

nslookup

iwconfig

A wireless network interface is configured using the iwconfig command. You may view and modify the SSID and encryption of your wireless network. Here is the implementation of iwconfig network command in Linux.

iwconfig

ifplugstatus

This command informs us of the presence or absence of a cable hooked into our network interface. We have to install this in Linux because it is not already installed tool.

Here is the implementation of ifplugstatus after installation.

ifplugstatus

mtr

This is a combined version of traceroute and ping. For using it, we need to install mtr in Linux. It is a tool for network diagnostics that continuously delivers packets with the ping time for each hop shown in them. Additionally, it shows any network issues encountered throughout the complete path that network packets follow. Let's check mtr command for codingninjas.com.

mtr

arp

The arp network command in Linux stands for Address Resolution Protocol. We can access or add data to the kernel's ARP table using this. Here is the implementation of arp.

arp

route

The route command displays and modifies your system's IP routing table. A router is a device that is primarily used to choose the optimal path for packets to take in order to reach their destination. Here is the implementation of the route.

route

whois

A website's record is described in detail by the whois command. You may find out everything there is to know about a website, including its registration details and who the owner is. Let's check it for codingninjas.com by performing the whois network command in Linux.

whois

nmap

Nmap, often known as "Network Mapper," is a potent tool for network management, security audits, and discovery. It is often used by system administrators to identify which of their systems are online as well as for OS and service detection.

The ports, their status (open or closed), and protocols are displayed by default in the Nmap scan. It sends a packet to 1000 of the most popular ports and waits for a reply.

Here is the basic implementation of nmap in Linux.

nmap

iperf

Ping checks a host's accessibility, whereas iperf analyses and measures network performance between two hosts. You can establish a connection between two hosts and send data using iperf. The available bandwidth between the two hosts is then displayed by iperf. Here is the implementation of iperf in Linux.

iperf

All the above-mentioned network commands in Linux are the most important commands which you can use for making communication between two or more hosts, two or more systems or machines, etc.

Also read, nmap commands

Frequently Asked Questions

Why do we use network commands?

Networking commands are used at the command prompt to obtain network information such as the system's IP address (remember that an IP address is your device's address in a network), MAC address, network route taken by a packet, and the IP address of the server hosting a website or URL.

What are the types of network interfaces in Linux?

There are two types of network interfaces in Linux physical and virtual.

Why do we use netstat command in Linux?

A networking utility for configuration and troubleshooting that may also be used to keep track of network connections is the network statistics (netstat) command.

Why does networking utilize Linux?

Network engineers can now use tools and applications previously only accessible for servers since they have access to the native Linux shell.

Where can we find ipconfig in Linux?

For ipcofig on Linux, you can simply write a command ip r.

Conclusion

In this article, we have learned the use of network commands in Linux. We have discussed all those different network commands. We have discussed why to use them and how we can use them. To learn more about Kali Linux:

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy Coding!

Live masterclass