grep finds lines that match a pattern. It is the fast way to hunt errors in logs without opening the whole file.
Steps
On Ubuntu it is usually installed. If missing:
sudo apt updatesudo apt install -y grepSearch a string in a log (line numbers, ignore case):
grep -ni "error" /var/log/nginx/error.logSearch a tree recursively and list only matching files:
grep -RIl "TODO" /var/wwwPipe journalctl for systemd services:
sudo journalctl -u nginx --since "1 hour ago" | grep -i fail
Tips
- Use
grep -E(oregrep) for extended regular expressions. - On large trees, add
--include="*.log"so you skip binaries.
ext step
Logs and root on your own box: Deploy your Cloud VPS.