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.
Asked
Active
Viewed 5.1k times
1 Answers
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 | moreTo view view only TCP connections :
sudo lsof -i -n -P | grep TCP | moreTo view view only UDP connections :
sudo lsof -i -n -P | grep UDP | more
Sachin S Kamath
- 1,417
- 1
- 12
- 20
-
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 S Kamath Jan 14 '15 at 10:53