Basic Networking Command In Linux


Your connection to a network is made by your system through a particular hardware interface such as an Ethernet card of a modem. Data passing through this interface is then routed to your network. The ifconfig command configures your network interfaces and the route command sets up the network connections accordingly.
Ifconfig is used to configure the kernel-resident network interfaces.It is used at boot time to set up interfaces as necessary. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only.
Syntax : ifconfig < interface > < -host_net_flag > [address] [options]
where -host_net_flag can be either -host or -net to indicate a host or network IP address.
The -host flag is the default.
Usage Examples
#ifconfig eth0 => Configuring the Ethernet interface
#ifconfig eth0 broadcast netmast  => Configuring eth0 including a broadcast address and the netmask
#ifconfig eth0 up  => To activate the interface eth0 after configuring it
#ifconfig -a  => If a single -a argument is given, it displays the status of all interfaces, even those that are down


Determines where the process starts and to what computer your system needs to send the packet to reach the destination.
Usage Examples
#route  => To display the routing table
#route add dev eth0  =>  To route an Ethernet interface
#route del  =>  To delete the route with IP address
For a gateway we first need to add a route and then add a route specifying it is a gateway.
#route add
#route add default gw  =>  gw here stands for gateway
#route add -net gw dev eth1 => For a gateway to access a subnet
To add an IP address to another network interface we use the ifcofig and route commands with the new IP address.
#ifcofig eth1
#route add dev eth1


ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbour for a given IPv4 Address.
Usage Examples
#arp -e  => Display all ARP table entries for all interfaces
#arp -i eth0 -s 00:23:5a:c1:50:99  => Create a static ARP table entry associating IP address with MAC address 00:23:5a:c1:50:99 available through the eth0 interface ( ‘i’ option stands for interface and ‘s’ option is used for setting up new table entry )
#arp -d  => Delete the ARP table entry for


Traceroute is a utility that traces a packet from your computer to an Internet host showing how many hops the packet requires to reach the host and how long each hop takes.For a slow connection traceroute is used to check the route through which we are connected to a host , monitoring the speed and the number of intervening gateway connections a route takes.
Usage Example
#traceroute www.google.com
Sample Output for the above command:
traceroute to www.google.com (, 30 hops max, 60 byte packets
1 ( 1694.355 ms 1694.510 ms 1694.847 ms
2 iws1.iiita.ac.in ( 0.869 ms 0.864 ms 0.902 ms
3 * * *
4 * * *
5 ( 66.756 ms 66.750 ms 66.730 ms
6 ( 69.556 ms 69.287 ms 69.279 ms
7 ( 62.766 ms 62.797 ms 64.210 ms
8 ( 64.153 ms 64.162 ms 65.593 ms
9 ( 65.855 ms 65.849 ms 64.820 ms
10 maa03s04-in-f16.1e100.net ( 62.011 ms 62.001 ms 61.982 ms


Provides real time information on the status of the network connections, as well as the network statistics and routing table.
Usage Examples
#netstat -r       =>  Displays the routing table
#netstat -i       =>   Displays the uses of the different network interfaces.
#netstat -s      =>   Displays protocol( TCP , UDP , IP etc ) counts and errors


To remotely log in to another system on your network. Telnet operates as if we were logging in to another system from a remote terminal and asks for the login name and password.
#telnet hostname < port >
telnet > open hostname < port >
Here the hostname can be either the domain name or the IP address.


Nslookup is a command used to query the Internet domain name servers. Is useful in finding the domain name if the IP is known and vice-versa.
The host command can be used to carry out the same stuff too.
Usage Examples
#nslookup < domain name >        => To find the dotted decimal IP address of host name
#nslookup < IP address >            => To find the hostname of the dotted decimal IP address


Detects whether a system is up and running.
Syntax : ping hostname
where hostname can be either domain name or IP address.
Usage Examples
From icmp_seq=1 Destination Host Unreachable
From icmp_seq=2 Destination Host Unreachable
From icmp_seq=3 Destination Host Unreachable
From icmp_seq=4 Destination Host Unreachable
From icmp_seq=5 Destination Host Unreachable
From icmp_seq=6 Destination Host Unreachable
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=128 time=4.00 ms
64 bytes from icmp_req=2 ttl=128 time=4.56 ms
64 bytes from icmp_req=3 ttl=128 time=0.931 ms
64 bytes from icmp_req=4 ttl=128 time=4.10 ms
64 bytes from icmp_req=5 ttl=128 time=1.08 ms
64 bytes from icmp_req=6 ttl=128 time=6.78 ms
Here in the first case the destination host is unreachable whereas in the second case the destination sends the packets back ensuring good connectivity.


ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network.
Syntax : ssh username@hostname [command]
where username is your SSH username, and hostname is the host name or IP address of your Web server.
If its the first time we are trying to connect to this host machine we will get a warning saying authentication failure. Typing yes would automatically solve the problem.
Usage Examples
#ssh raju@ -p 1020  => ssh as user raju into port 1020
#ssh raju@ cd /home/etc  => change the directory to /home/etc in the remote server