Thursday, 6 February 2014

Linux Network Commands

Posted by Mahesh Doijade 3 Comments

Linux Networking Commands, Networking Commands

Making optimal use of the network with Linux for varied purposes such as remote login, network statistics, alive test, and many more, is very essential in day-to-day usage. Linux Networking is incredibly simplified with the following elaborated Linux Network Commands.

Linux Network Commands in a Nutshell

ifconfig [devicename] [reqd. action] [options] : With this command and its different options one can obtain statistics as well as configure any network adapter connected in the system.
example : To assign IP Address to a  network adapter.
ifconfig eth0

whois [options]  <arg[@server]> : Queries the WHOIS database, to retrieve available information about the given server / domain-name.
example : To obtain information about a domain, suppose

ping [options] [host-address/name] : This command sends Internet Control Message Protocol (ICMP) to the specified network host.
example : To ping a network host ""

netstat [options] : Gives information about the all the network connections established by the system through different ports.
-t  : Displays only TCP socket connections
-a : Displays all the sockets that is listening and non-listening ones
For example :
netstat -a

traceroute [options] [host-name/address] : Displays identity of hosts visited by the packet while routing from its source to destination.
-n : This option disables the DNS lookups for the IP Addresses
example :

route [options] [destination host-name/address] : Displays as well as allows to manipulate the IP routing table.
-n : Displays IP addresses as by default hostnames are displayed
example : The command below displays the numerical IP addresses in the IP routing table
route -n

telnet [options] [host] [port_number] : Does an interactive communication with another host through TELNET protocol on the specified port number. By default it uses TCP port number 23 and the connection is not encrypted.
-l : specify user name to login as on the remote system
example : To login into remote host in username "abc"
telnet -l abc

ssh [options] [username@host-address] : Enables a user to make secure remote login to the specified host address.
-C : Compresses the data which sent over the connection to specified host
-X : Enables the user to use X server features. 
example : In order to ssh to host with username "abc" following is the command.
ssh -X abc@

scp [options] [username@host-address:file_location] : Enables a user to make secure copy of the file to the specified host-address.
-r  : Recursively copies the data in directories
-C : Compresses the data which sent over the connection to specified host
example : In order to scp file.txt to host with username "abc" following is the command.
scp file.txt abc@\

wget [options] [URL] : Performs HTTP request from through the shell to get data from the URL
-r  : Get the URL and all its links in recursive manner

iptables [options] : This command requires root permission. It enables to carry out packet filtering and Network Address Translation.
-F  : Flush set of rules
-n  : Show rules without carrying out DNS lookups
-A :  Appends one or more rules to the end of the selected chain.
-j   : Specify the target of the rule
-s  : specify source
-L : Current rules are listed
For example : To block packets from certain IP Address, can be done by
iptables -A INPUT -s -j DROP

tcpdump [options] : Outputs the contents of packets on the network interface. It can also output only certain packets based on the condition provided.

Read More