10

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.

15

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

  • 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. – Mohammad Nikkhou Jan 14 '15 at 10:27
  • run the following command : sudo apt-get install lsof and install lsof. – Sachin Kamath Jan 14 '15 at 10:53

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.