Script to list all the open ports

This could be a very good utility to check the open ports in the server.

#!/bin/sh

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin

if [ -e /etc/master.passwd ]; then
netstat -an | grep LISTEN | grep “*” | awk ‘{print $4 }’ | cut -d. -f2 | sort -n | uniq
else
netstat -an | grep LISTEN | grep -v STREAM | grep : | awk ‘{print $4 }’ | cut -d: -f2-4 | cut -d : -f3 | sort -n | uniq

Filed Under: Quick fixesTechnical

Tags:

About the Author: InstaCarma is a provider of Enterprise Class Solutions for the Hosting Industry

RSSComments (0)

Trackback URL

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes
InstaCarma provides outsourced web hosting technical support, helpdesk management, datacenter automation, cloud service management. Sales - 1800 810 6547 - visit www.instacarma.com