How to check and open ports in Linux

The most common host-based tool for checking for open ports on Windows or Unix systems is the netstat command.

To see open TCP Network Ports :- 
vishal@vyas:~# netstat -vatn

To see DNS Hostnames :- 
vishal@vyas:~# netstat -vat


To see open UDP Network Ports:- 
vishal@vyas:~# netstat -vaun



===================================================================

Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. Nmap can provide further information on targets, including reverse DNS names, operating system guesses, device types, and MAC addresses.


vishal@vyas:~# nmap -sS 10.10.10.50

Starting Nmap 4.53 ( http://insecure.org ) at 2011-12-26 12:35 IST
Interesting ports on vishalvyas.com (10.10.10.50):
Not shown: 1703 closed ports
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
110/tcp   open  pop3
111/tcp   open  rpcbind
139/tcp   open  netbios-ssn
143/tcp   open  imap
445/tcp   open  microsoft-ds
993/tcp   open  imaps
995/tcp   open  pop3s
3306/tcp  open  mysql
10000/tcp open  snet-sensor-mgmt

Nmap done: 1 IP address (1 host up) scanned in 0.404 seconds.


general structure of a nmap command is
#nmap <options> <ip address>
Some of important nmap command line options are
-A : which is used for telling Nmap to use advance options of Nmap(like OS finger printing).
-O : For OS finger printing ie finding out Operating system running in the remote host. 

Thanks,
Vishal.