How do you check whether a port currently being used? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

How do you check whether a port currently being used?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-11-2009
rajesh08 rajesh08 is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 1 December 2009, 5:49 PM EST
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
How do you check whether a port currently being used?

Hi,

Please help me out, how to check whether a port currently being used or not.
is there any command which give the result?

Thanks
Rajesh
Sponsored Links
    #2  
Old 03-11-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 24 October 2014, 1:54 PM EDT
Location: St. Gallen, Switzerland
Posts: 6,237
Thanks: 121
Thanked 453 Times in 412 Posts
You can check it with netstat -a and search for either port name associated with /etc/services or just the portnumber if it is not listed in /etc/services.
You can see stati like ESTABLISHED and others.

To check remote if a port is available or not, you can use nmap. It doesn't say if this port is currently being used though. Just have a loot at it as additional info
Sponsored Links
    #3  
Old 03-11-2009
Autocross.US's Avatar
Autocross.US Autocross.US is offline
Registered User
 
Join Date: Nov 2008
Last Activity: 10 October 2010, 2:11 PM EDT
Location: Chesapeake, VA
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
lsof -i :<portnumber>

example:

lsof -i :80
    #4  
Old 03-11-2009
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 24 October 2014, 4:42 PM EDT
Location: Switzerland - GE
Posts: 5,835
Thanks: 162
Thanked 415 Times in 390 Posts
lsof isnt a unix command... but a opensource utility that might not be installed...
Sponsored Links
    #5  
Old 03-13-2009
amitranjansahu's Avatar
amitranjansahu amitranjansahu is offline
Registered User
 
Join Date: Jan 2009
Last Activity: 6 February 2014, 9:06 AM EST
Location: Bangalore,INDIA
Posts: 507
Thanks: 4
Thanked 27 Times in 27 Posts
netstat -an | grep <port number>

ex -
netstat -an | grep 5060
Sponsored Links
    #6  
Old 05-13-2009
sikander sikander is offline
Registered User
 
Join Date: May 2009
Last Activity: 8 September 2009, 3:18 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ports and services

Hi All,

Can some guide me how can i check this 49152 port or any port is used by which service and how can I block it.

Thanks in advance. Looking forward to hear from you guys.

Regards,

Sikander
Sponsored Links
    #7  
Old 05-13-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
code tag tagger
 
Join Date: Sep 2007
Last Activity: 24 October 2014, 1:54 PM EDT
Location: St. Gallen, Switzerland
Posts: 6,237
Thanks: 121
Thanked 453 Times in 412 Posts
Hi, please open a new thread next time instead of digging out this old one.

There is some information to your question already in this thread.
If you don't have an entry in your /etc/services, you can try with the command (if available) "lsof" if you can see what uses this port. Also you can check with netstat -a for example if it is up and what status it has.
For blocking ports you might want to use a firewall; depending on your system on Linux you could use ipchains/iptables.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to check that a device is attached on a port narendra.pant Solaris 2 07-15-2008 11:47 PM
how to check status of various services and port? ashish4422 AIX 1 04-16-2008 02:14 PM
How to check the TCP/UDP port of a connection tayyabq8 UNIX for Dummies Questions & Answers 2 05-18-2006 12:55 AM
How can I check what port addresses used the application eykyn17 IP Networking 1 02-16-2006 11:58 AM
how can i check if port is busy or if someone is using it ? umen IP Networking 1 01-28-2006 02:37 AM



All times are GMT -4. The time now is 12:18 AM.