Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

Monday, July 26, 2021

Top 10 basic networking commands in linux/unix - Examples

Networking is an essential part of Unix and it offers lots of tools and commands to diagnose any networking problem. When I was working on FIX Protocol we get a lot of support queries to see whether FIX Sessions are connected or not. Since FIX Protocol uses sockets you can use the netstat, telnet, and other networking commands available in Linux for finding a problem and solve that. In this article, I will show you basic networking commands in Unix and for what purpose they are used. with the combination of grep and find command on them, you can troubleshoot most of the networking problems.

Networking Commands Example in Unix and Linux

These are the most useful commands in my list while working on a Linux server, this enables you to quickly troubleshoot connection issues e.g. whether another system is connected or not, whether another host is responding or not, and while working for FIX connectivity for an advanced trading system this tools saves quite a lot of time

This article is in continuation of my article How to work fast in Unix and Unix Command tutorials and Examples for beginners.

• finding host/domain name and IP address - hostname
• test network connection – ping
• getting network configuration – ifconfig
• Network connections, routing tables, interface statistics – netstat
• query DNS lookup name – nslookup
• communicate with another hostname – telnet
• outing steps that packets take to get to network host – traceroute
• view user information – finger
• checking status of destination host - telnet

10 Example of Networking commands in Unix

let's see some examples of various networking commands in Unix and Linux. Some of them are quite basic e.g. ping and telnet and some are more powerful e.g. nslookup and netstat. When you used these commands in a combination of find and grep you can get anything you are looking for e.g. hostname, connection endpoints, connection status, etc.

For a complete list of UNIX commands, you see The Linux Command Line: A Complete Introduction, a great book, and a must-read for any UNIX user.

Basic Linux UNIX Networking commands

1. hostname

hostname with no options displays the machine's hostname
hostname –d displays the domain name the machine belongs to
hostname –f displays the fully qualified host and domain name
hostname –i displays the IP address for the current machine

2. ping

It sends packets of information to the user-defined source. If the packets are received, the destination device sends packets back. Ping can be used for two purposes

1. To ensure that a network connection can be established.
2. Timing information as to the speed of the connection.

If you do ping it will display its IP address. Use ctrl+C to stop the test.

3. ifconfig

View network configuration, it displays the current network adapter configuration. It is handy to determine if you are getting transmit (TX) or receive (RX) errors.

4. netstat

Most useful and very versatile for finding a connection to and from the host. You can find out all the multicast groups (network) subscribed by this host by issuing "netstat -g"

netstat -nap | grep port will display process id of application which is using that port
netstat -a  or netstat –all will display all connections including TCP  and UDP  
netstat --tcp  or netstat –t will display only TCP  connection
netstat --udp or netstat –u will display only UDP  connection
netstat -g will display all multicast network subscribed by this host.

5. nslookup

If you know the IP address it will display the hostname. To find all the IP addresses for a given domain name, the command nslookup is used. You must have a connection to the internet for this utility to be useful, e.g. 


You can also use the nslookup to convert hostname to IP Address and from IP Address from the hostname.

6. traceroute

A handy utility to view the number of hops and response time to get to a remote system or website is a traceroute. Again you need an internet connection to make use of this tool.

7. finger

View user information, displays a user’s login name, real name, terminal name, and write status. this is pretty old Unix command and rarely used nowadays.

8. telnet

Connects destination host via the telnet protocol, if telnet connection establishes on any port means connectivity between two hosts is working fine.

$ telnet hostname port   

will telnet hostname with the port specified. Normally it is used to see whether the host is alive and the network connection is fine or not.

Basic Linux Networking commands

If you are like MySQL as your database you may find my MySQL commands tutorial series useful. 

Other UNIX Command Tutorials and Examples


sumit said...

some imp examples please show then only site be improve

Llawiso said...

good work, but there are only 9 commands... the 10th command is nmap, isn't it?

Unknown said...

Yeah nmap is a command that will list down all the devices connected in the network.

Unknown said...

Telnet? Really?

Anonymous said...

finger a network command? I first used it on a stand-alone machine that was NOT connected to the net. Then it's described as a "pretty old Unix command that is hardly used nowadays". What's the point of including it here?

Unknown said...

Beware do not use hostname with flags in another Unix flavour, this will change the hostname to the flag alphabet .
Eg : hostname -d in solaris will change the hostname to "- d"

javin paul said...

@Ranju, thanks, very useful information.

jazz said...

i like it

javin paul said...

Thank you Jazz

Post a Comment