Find the answer to your Linux question:
Results 1 to 6 of 6
Hi every one ... Is there any linux command to find the port number of a program or application. I have tried $ netstat -nlp but it won't list the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2008
    Posts
    4

    how to find port number


    Hi every one ...
    Is there any linux command to find the port number of a program or application.
    I have tried
    $ netstat -nlp

    but it won't list the port number .it just lists the PID and the program using it.

  2. #2
    Just Joined!
    Join Date
    May 2008
    Posts
    12
    please show output of netstat -lnp

  3. #3
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    When you run 'netstat -lnp under Local Address you'll see something like this;

    0.0.0.0:#

    The ':#' is the port.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  4. #4
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Quote Originally Posted by Lazydog View Post
    When you run 'netstat -lnp under Local Address you'll see something like this;

    0.0.0.0:#

    The ':#' is the port.
    My version of netstat doesn't display the Local Address field with those options but netstat -atun does the trick.

    You can also nmap localhost for a quick list of open ports and the programs that are listening on them. You should be able to yum install nmap if you get a 'command not found.'

  5. #5
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Quote Originally Posted by Thrillhouse View Post
    My version of netstat doesn't display the Local Address field with those options but netstat -atun does the trick.

    You can also nmap localhost for a quick list of open ports and the programs that are listening on them. You should be able to yum install nmap if you get a 'command not found.'
    Are you sure about this? I see them using either '-lnp' or '-atun'
    I am running RHEL 4.6 here.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  6. #6
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    Quote Originally Posted by Lazydog View Post
    Are you sure about this? I see them using either '-lnp' or '-atun'
    I am running RHEL 4.6 here.
    Well, I tried it on a UNIX version of netstat, not Linux. Slightly different implementations of netstat, I suppose. Nevertheless, I just tried it on CentOS and I think the -atun options are more readable; they don't show the UNIX domain sockets which don't show the Local Address field and is what the OP might be seeing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •