LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   port availability- linux redhat 5 (https://www.linuxquestions.org/questions/linux-newbie-8/port-availability-linux-redhat-5-a-4175440263/)

vicky007aggrwal 12-06-2012 07:51 AM

port availability- linux redhat 5
 
Hi All,

I am using "lsof -i:<Port Number>" & "netstat -anp| grep <port number>" commands to check
the free ports available on my Linux(redhat) machine.

But the problem with above commands is that, it wont show the process details of a particular port
if it is running from an user account which is different with which i logged in.

Do we have any command or work around by which we can check whether a port is owned by any process (or any other user account )
even if we dont have root access.

Please suggest

acid_kewpie 12-06-2012 09:40 AM

Pretty sure it's not possible, maybe you can run it via sudo securely?

vicky007aggrwal 12-06-2012 09:42 AM

oh seriously , so there is no way out to find the ports owned by different user accounts as i dont have root or sudo access

chrism01 12-06-2012 11:02 PM

Actually, if you try eg netstat as non-root, it actually tells you this
Code:

netstat -tanp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)


vicky007aggrwal 12-06-2012 11:33 PM

I am not able to see the non-owned process info for a particular port,so only ROOT can check which all ports are owned by users

acid_kewpie 12-07-2012 02:13 AM

Quote:

Originally Posted by chrism01 (Post 4844244)
Actually, if you try eg netstat as non-root, it actually tells you this
Code:

netstat -tanp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)


you got the options wrong, it should be -pant. Sadly -s can't be used, otherwise I'd get to write -pants a dozen times a day. ;-)

chrism01 12-07-2012 03:52 AM

Nice :) ;)

vicky007aggrwal 03-12-2013 06:02 AM

I am still getting below error , when i am using netstat -pant| grep 10003.It doesnt give the desired result


(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)

acid_kewpie 03-12-2013 10:28 AM

Quote:

Originally Posted by vicky007aggrwal (Post 4909857)
I am still getting below error , when i am using netstat -pant| grep 10003.It doesnt give the desired result


(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)

Where does it say that's an error? It clearly says that you need to be root... what else are we suppose to add?

vicky007aggrwal 03-12-2013 10:49 AM

I mean without being root does this mean that i cannot locate the process running on particular port if it is owned by differnt user id with which i logged in ?

acid_kewpie 03-12-2013 11:02 AM

yes, that would be a privilege violation if it were possible.

vicky007aggrwal 03-12-2013 01:18 PM

Thanks chris


All times are GMT -5. The time now is 06:13 PM.