Introduction
There are many networking commands available in the Linux operating system. Some of the basic commands that we use as a beginner to networking are listed below with an example and little explanation. It will give a brief understanding of commands.
Basic Networking Linux Commands List |
Some of the basic networking commands used in Linux.
ifconfig / ip
In order to get the information and configure the network interface, we used the ifconfig or ip commands. It can be further used to manipulate the routing, network devices, and interface of the network.
Example: In order to list all the network interface and its related ip address, the commands are
- ifconfig -a
- ip -a add show
ping
The ping command is used to check whether the network devices are reachable in the network. It sends the ICMP ECHO_REQUEST to the network host. You can ping with the ip address or the url address.
Example: If the ip address of the host is 10.10.10.10, then the command used is
- ping 10.10.10.10
By default, it will ping the host continuously. So if you want to send a limited number of ping then you have to issue the count argument indicating the number of times that you want to ping. If you want to ping 4 times then the command is
- ping -c 4 10.10.10.10
host
It is a DNS lookup utility tool used to find the ip address from the known domain and vice versa.
Example: if your domain is www.youtube.com then to find the ip address the command is
- host www.youtube.com
It will give you some corresponding ip address. Now if you want to find the domain name from the given ip address(10.10.10.10) then the command is
- host 10.10.10.10
It will give you the domain name. The ip address that I have used is a dummy one. So if you want to try that command use the valid ip address.
arp
It is used to manipulate the system ARP cache. ARP stands for Address Resolution Protocol.
Example: In order to display the arp table the command is
- arp -a
It will display the address, hardware address, interface name and so on.
dig
It is also a DNS lookup utility tool. It stands for Domain Information Groper. It is used to do the query about the Domain Name System in the name server.
Example: If you have the domain name as gcit.edu.bt then the command used is
- dig gcit.edu.bt
nslookup
It is used to query the internet name server interactively. It stands for Name Server Lookup. It will also give you information about the specific DNS record. You can either give the ip address or the domain name.
Example: If the domain name is gcit.edu.bt, then the command is
- nslookup gcit.edu.bt
netstat
It will print the network connections information, routing table, interface statistics and so on regarding the network. The alternative to netstat command is ss command-line utility tool.
Example: In order to list the routing table the command is
- netstat -r
If you want to list both listening and non-listening sockets the command is
- netstat -a
The alternative command-line tool is
- ss
traceroute
It traces the path to a host in the network. You can either use ip address or url address in order to trace its route.
Example: If you want to find the path to www.google.come, the command is
- traceroute www.google.com
The alternative to the above command is tracepath. The command is
- tracepath www.google.com
tcpdump
It is used to capture and analyze the traffic in the network. You can even save the captured packets and used it to analyze later. It is one of the most powerful networking command-line tools.
Example: If you want to capture the packets of any interface the command is
- sudo tcpdump -i any
In case if you want to capture packets in specific network interface(eth0 interface), then the command is
- sudo tcpdump -i eth0
wget
In order to download the file from the internet using a command line, the wget command is used. It is the non-interactive network downloader. You just have to provide the url of your file that you want to download.
Example: If the file that you want to download is at this url ftp://files.gcit.edu.bt/Application/rufus-2.18.exe, then the command to download is
- wget ftp://files.gcit.edu.bt/Application/rufus-2.18.exe
ssh
If you want to access your system remotely, then one way to do it is through ssh connection. It stands for Secure Shell. It uses the encryption method to establish the connection between the client and the host. It uses port number 22 to connect.
Example: If your host ip address is 10.10.10.10 and the user name is user_name, then the command used to connect to 10.10.10.10 is
- ssh user_name@10.10.10.10
It will ask you to enter the password once the connection is established. Then you will be able to access the 10.10.10.10 host remotely.
Conclusion
These are some of the basic networking commands that you need to know as a beginner to networking in the Linux operating system. If you want to know more about the specific command you can use the man command in the terminal to get more information about it. If you have any doubts or confusion feel free to leave a comment in the comment section below.