Like other Operating System, Linux is also a multi-tasking and multi user Operating System. The systems are connected each other through networking media to exchange information each other. That being said, every Linux System talks to other system through network and it’s media. The network configuration of a system is also a part of System Admin profile. So, to be a good System Administrator you should have a sound knowledge of Networking also. In this post, we are going to see some essential Linux networking commands which may be useful in daily operations.
Also Read:-
Linux commands Part-1
Linux commands Part-2
Linux commands Part-3
Linux commands Part-4
1. ip or ifconfig
The ip command is available quite some time now. But the people are still using deprecated ifconfig command. An ip command is more powerful and is going to replace ifconfig command in coming days. With ip command we can configure IP address to the interface instantly and also can add or remove route in routing table. Also you can see the network devices and configuration details like IP Address, Gateway, MAC or Ethernet address of NIC etc.
Below command shows Interfaces details like IP Address, Gateway, Ethernet address etc.
# ifconfig
# ip addr show
Enable a single network interface with command below (In your case interface name may vary).
# ifconfig enp0s3 up
# ip link set enp0s3 up
Disable single network interface with command below(In your case interface name may vary).
Sample output
ping is the very first command to check the availability or reachability of the system which sends ICMP “Echo Request” to the interface and waits for response. Ping is use to test the connectivity and determine the response time. If we won’t get a reply for a certain period of time, that means either system is dead or system is not in a network.
traceroute command is deprecated and unavailable in CentOS/RHEL 8 version and same is replaced by tracepath command. This is a very important command to find the path used by packet to reach a destination. This tool is very helpful for troubleshooting to narrow down the network unreachable issue.
netstat command is also deprecated and replaced by ss command. However, it’s still available most of the Linux system. The ss command is to dump socket statistics and display information like netstat command. With this command, you will get detail information about how the Linux system is communicating with other system. This tool helps for troubleshooting of various networking issues.
# ss -t -a
-a : Display all Listening or Established TCP connections
-t : tcp connections
Sample output
# ip route add 172.24.24.0/24 via 172.24.24.1 dev enp0s3
6. dig
Domain Information Gropher aka DIG command is to query DNS information of domain. It is also use for troubleshooting of DNS related issue.
Sample output
A : “A” record for domain
NS : “Name Server” for domain
AAAA : IPv6 “A” record
To know more about nslookup command do “man nslookup“ from console.
8. host
host command is also to perform DNS lookups it will resolve hostname to IP address or vice-versa.
9. nmcli
Network Manager Command Line tool “NMCLI” which is use to control NetworkManager. nmcli command is to create, show, edit, interface up or down. Also you can manage teaming information using nmcli command.
10. telnet
11. tcpdump