linux - finding a process ID and listing the command name and any network connections -
i've been trying create script take process id number (pid) , identify process id name , list network connections connected to.
i understand should use netstat this. here code far doesn't seem anything, can explain im going wrong , need do?
echo 'please enter process id: ' read pidn echo 'you entered process id: ' $pidn pid= pgrep -fl "^(/.*)?${pidn}\s" echo $pid
if use command below (ex: ssh)
netstat -nalp | grep -i ssh
follow result:
[root@localhost ~]# netstat -nalp | grep 1055 tcp 0 0 0.0.0.0:22 0.0.0.0:* listen 1055/sshd tcp6 0 0 :::22 :::* listen 1055/sshd unix 3 [ ] stream connected 20308 1055/sshd
Comments
Post a Comment