17

I want to find a list of all network services running on my system, including details of the port and services and the users. I know that I need to use netstat, ps and fuser. but I don't know how to write the command. Do I need to write a shell script to find all of them? or I can use in a line of commands? Thanks for your help.

1 Answer 1

23

Use the command : sudo lsof -i -n -P

This command lists the Application Name, PID, User, IP version, Device ID and the Node with Port Name. It shows both TCP and UDP.

Variations :

  • To format it in a nice, readable way; use :

    sudo lsof -i -n -P | more

  • To view view only TCP connections :

    sudo lsof -i -n -P | grep TCP | more

  • To view view only UDP connections :

    sudo lsof -i -n -P | grep UDP | more

2
  • Thanks boddy, I don't have lsof command, it is a basic system and I have to use those 3 commands of ps, fuser and netstat together to find the users. Jan 14, 2015 at 10:27
  • run the following command : sudo apt-get install lsof and install lsof. Jan 14, 2015 at 10:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .