Skip to main content

Shell

find exposed ports:
netstat -lntu
ss -lntu
find process on port
lsof -nP -iTCP -sTCP:LISTEN | grep <port-number>
try to find error logs of some running process
#find PID
ps aux | grep httpd
#PID -> 1234
#then find open log files with lsof
lsof -p 1234 | grep log
apply command to several items
echo {1..4} | xargs -n1 -I{} ssh root@www{}.example.com hostname
recursive search in files
grep -r "searchterm"
# recursive search with maxdepth
find . -maxdepth 5 -type d | grep "searchterm"