Summery
grep is a Linux/Unix command used to search text for lines matching a pattern.
Commands
grep -i "admin" file.txt - Case-insensitive search.
grep -i -R "admin" /etc/ - Look recursively through the folder.
grep -v "admin" file.txt - Show lines NOT matching.
grep -n "admin" file.txt - Show matching line numbers.
grep -r "admin" . - Recursively search files.
grep -l "admin" *.txt - Show filenames containing a match.
grep -c "admin" file.txt - Count matching lines.
grep -E "admin|root" file.txt - Use extended regular expressions.
grep -o "admin" file.txt - Show only the matching text.
grep "*sh$" /etc/passwd - Check for users with an actual shell .
grep -rnw "PRIVATE KEY" /* 2>/dev/null | grep ":1" - Look for private keys.
grep -rnw "ssh-rsa" /home/* 2>/dev/null | grep ":1" - Look for private keys.