chris clarke
software development that works…or something
Find which process is listening on a port
October 17, 2007 on 6:20 pm | In Unix | No CommentsTo find which process is listening on port 22:
lsof -i:22
Find out which port a process is listening on e.g. httpd:
lsof -P -c httpd -a -i
Or by PID:
lsof -P -p 267 -a -i
lsof can also be used to find the files a process has open. To look for where httpd writes it’s log files:
lsof -c httpd | grep log
Unix stuff
October 17, 2007 on 5:58 pm | In Unix | No CommentsIf you work a lot on slow Solaris boxes, you can speed up finds a little bit:
find . -depth -type f -name '*.monkeys'
The depth option looks at the contents of directories before the directory itself and the ‘type f’ constricts the find to only look at regular files. You can speed it up a bit more if you have more information about the file e.g. the owner:
find . -depth -type f -user dev -name '*.monkeys'
Looking for something inside a file and only want to list the files containing your search:
grep -l monkeys *
Working on a box that doesn’t have recursive grep:
find -X . -depth -type f -name '*' | xargs grep -l monkeys
The ‘-X’ option ignores files that would mess with xargs e.g. filenames with spaces in.
Powered by Cheese.
RSS Entries Feed.
RSS Comments Feed
^Top^