My Favourite Grep / Bash Combo’s

Just a quick build up of my most commonly used bash commands

lsof | grep ‘searchterm’  – List open files and search for specific handle
history | grep ‘searchterm’ – Search for a term in my bash history (I now have this setup as an alias ‘ghistory’
ps -ef | grep ‘process’ – Much the same as ‘ps aux | grep’ but is HP-UX compatible, so force of habit really.
!ssh – Reuse the last ssh command in history (make sure you never use !rm, especially if you ever use rm -rf).
netstat -anp | grep ‘searchterm’ – Great for finding which processes are talking on which ports and to which ip addresses.

That’s it for the moment, I’ll keep them coming shortly.

Technorati Tags: , , , ,

Published by salubrium

I am a Systems Administrator based in Sydney, Australia with some hugely varied interests: Topics covered are Virtualization, Web Hosting, Remote Desktop, Security and Backups, PHP, Python, MVC Frameworks, SEO

Leave a comment

Your email address will not be published.