An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or
all the files in a file system may be selected by path.
In Solaris lsof is present in /usr/local/bin/lsof usually.
lsof | grep
lsof
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Good document for finding out the same information on Linux is: http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/security-guide/s1-server-ports.html
For HP-UX, lsof is not part of the standard install. You can download it from:
http://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/binaries/hpux/
#!/bin/bash
# Get the process which listens on port
# $1 is the port we are looking for
if [ $# -lt 1 ]
then
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
exit
fi
echo "Greping for your port, please be patient (CTRL+C breaks) ... "
for i in `ls /proc`
do
[ -d /proc/$i ] && pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
then
echo Is owned by pid $i
fi
done
No comments:
Post a Comment