Basic Network Commands in Unix PDF
Basic Network Commands in Unix PDF
Basic Network Commands in Unix PDF
1. ifconfig
ifconfig (interface configurator) command is use to initialize an interface, assign IP Address to interface
and enable or disable interface on demand. With this command you can view IP Address and Hardware /
MAC address assign to interface and also MTU (Maximum transmission unit) size.
# ifconfig
collisions:0 txqueuelen:1000
collisions:0 txqueuelen:0
ifconfig with interface (eth0) command only shows specific interface details like IP Address, MAC
Address etc. with -a options will display all available interface details if it is disable also.
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:28:FD:4C
collisions:0 txqueuelen:1000
Assigning an IP Address and Gateway to interface on the fly. The setting will be removed in case of
system reboot.
Enable eth0
# ifup eth0
Disable eth0
# ifdown eth0
By default MTU size is 1500. We can set required MTU size with below command. Replace XXXX with
size.
2. PING Command
PING (Packet INternet Groper) command is the best way to test connectivity between two nodes.
Whether it is Local Area Network (LAN) or Wide Area Network (WAN). Ping use ICMP (Internet Control
Message Protocol) to communicate to other devices. You can ping host name of ip address using below
command.
# ping 4.2.2.2
OR
# ping www.tecmint.com
In Linux ping command keep executing until you interrupt. Ping with -c option exit after N number of
request (success or error respond).
# ping -c 5 www.tecmint.com
3. TRACEROUTE Command
traceroute is a network troubleshooting utility which shows number of hops taken to reach destination
also determine packets traveling path. Below we are tracing route to global DNS server IP Address and
able to reach destination also shows path of that packet is traveling.
# traceroute 4.2.2.2
4. NETSTAT Command
Netstat (Network Statistic) command display connection info, routing table information etc. To displays
routing table information use option as -r.
# netstat -r
For more examples of Netstat Command, please read our earlier article on 20 Netstat Command
Examples in Linux.
5. DIG Command
Dig (domain information groper) query DNS related information like A Record, CNAME, MX Record etc.
This command mainly use to troubleshoot DNS related query.
;; Got answer:
;; ->>HEADER<
For more examples of Dig Command, please read the article on 10 Linux Dig Commands to Query DNS.
6. NSLOOKUP Command
nslookup command also use to find out DNS related query. The following examples shows A Record (IP
Address) of tecmint.com.
# nslookup www.tecmint.com
Server: 4.2.2.2
Address: 4.2.2.2#53
Non-authoritative answer:
Name: tecmint.com
Address: 50.116.66.136
For more NSLOOKUP Command, read the article on 8 Linux Nslookup Command Examples.
7. ROUTE Command
route command also shows and manipulate ip routing table. To see default routing table in Linux, type
the following command.
# route
Route Adding
Route Deleting
host command to find name to IP or IP to name in IPv4 or IPv6 and also query DNS records.
# host www.google.com
Using -t option we can find out DNS Resource Records like CNAME, NS, MX, SOA etc.
9. ARP Command
ARP (Address Resolution Protocol) is useful to view / add the contents of the kernel’s ARP tables. To see
default table use the command as.
# arp -e
ethtool is a replacement of mii-tool. It is to view, setting speed and duplex of your Network Interface
Card (NIC). You can set duplex permanently in /etc/sysconfig/network-scripts/ifcfg-eth0 with
ETHTOOL_OPTS variable.
# ethtool eth0