?
Solved

How to find if port taken in UNIX (Solaris 9)

Posted on 2007-11-28
10
Medium Priority
?
721 Views
Last Modified: 2013-12-27
Hello

2 questions (UNIX Solaris 9:

How do I find available ports on a unix system.

Also if I want to see if a port is listening, to see if the service using that port has started, what is the way to do this.

Thank you:)
0
Comment
Question by:atwork2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 1000 total points
ID: 20366856
Hi,

To see if a port is currently is in use and a process is listening to it, run

netstat -an | grep LISTEN

if you look at /etc/services , you will see the well know services ports (e.g. ftp, telnet, etc).

Any port that is not in use is a free one.

To verify also, you may use telnet to test tcp ports

e.g.

telnet ipaddress tcpport

telnet 10.0.0.1 25

if you get connected then the port is in use, if you get the message connection refused then it is not running.

0
 

Author Comment

by:atwork2003
ID: 20366980
Thank you this is really great.

also if I am logged into the server, can I do a grep for a specific port
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 1000 total points
ID: 20367035
Hi,

The netstat -an | grep LISTEN will give you this

or if it is tcp port you can try telnet but to the server ip or 0

e.g.

telnet 0 25

will connect you to port 25 on the local m/c you are logged to (unless the service is listening to a particular ip on the m/c)

or

e.g.

telnet serveripaddress 25
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Assisted Solution

by:robocat
robocat earned 500 total points
ID: 20367353

> also if I am logged into the server, can I do a grep for a specific port

Yes, suppose you want to check if port 256 is currently in use:

netstat -an | grep "*.256"

      *.256                *.*                0      0 49152      0 LISTEN

0
 
LVL 6

Assisted Solution

by:bpeterse
bpeterse earned 500 total points
ID: 20367727
If your intent is to create your own service on an open port - or to change ports for an existing service, you can refer to a list of assigned ports:services at the following links:
http://www.iana.org/assignments/port-numbers
http://www.iss.net/security_center/advice/Exploits/Ports/
http://www.chebucto.ns.ca/~rakerman/port-table.html

Any one that is not already assigned per IANA, then you can use it for your own purposes.  See the ff. links for adding new services/processes.

http://docs.sun.com/app/docs/doc/816-1048/6m7gaddjl?a=view#manageprogramprivileges-16
http://docs.sun.com/app/docs/doc/816-1048/6m7gaddjl?a=view#manageprogramprivileges-31
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20367814
Hi,

bpeterse:

Thank you for the links.

Do you think that the IANA ports are included in /etc/services file?

0
 
LVL 6

Expert Comment

by:bpeterse
ID: 20367903
I'm sure some are - but since I didn't understand his intent (as I indicated in the response), I thought I'd include that reference just to be thorough.  Just trying to help...
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20367974
Hi,

don't misunderstand me, I was trying to see if /etc/services has the up to date information of the well known ports.

Thank you again.
0
 

Author Closing Comment

by:atwork2003
ID: 31411453
I apologize for delay in closing. But exceptional help, can not thank you enough. Dont know what I would have done without my account on EE
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20515961
Welcome at any time.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question