Useful Linux Commands for Logs and File Search
Useful Linux Commands for Logs and File Search
When something breaks on a Linux system, the fastest path to answers is often the terminal.
This post focuses on commands that help you inspect logs, trace errors, and locate files quickly.
find
Use find when you need to locate files by name, type, or modification time.
find /var/log -name '*.log'
find ~/projects -type f -name '*.env'
find is powerful because it can search entire directory trees without extra tools.
tail
Use tail to inspect the end of a file or follow it live.
tail /var/log/syslog
tail -f /var/log/syslog
The -f flag is especially useful when watching logs during deployment or service restarts.
journalctl
On systemd-based systems, journalctl is often the best place to start.
journalctl -u nginx
journalctl -u nginx -f
journalctl --since "1 hour ago"
Filter by service and time window to narrow the output quickly.
grep
Use grep to isolate the lines that matter.
journalctl -u nginx | grep -i error
find /var/log -type f | grep nginx
You can combine grep with journalctl, find, or tail to reduce noise.
awk
Use awk when you need to print selected columns from structured output.
df -h | awk '{print $1, $5, $6}'
This is useful for quick checks of disk usage or system summaries.
Practical troubleshooting flow
-
Check recent service logs with
journalctl -
Search the output for errors with
grep -
Inspect related files with
find -
Use
awkorcutto format data when needed
These commands are small, but together they cover a large amount of real-world Linux troubleshooting.
Related Posts
Linux Commands Every Developer Should Know
A practical guide to the terminal commands that show up in daily development, debugging, and server work.
Demystifying Kubernetes Service Discovery
Unlock the full potential of Kubernetes with our comprehensive guide to service discovery, enabling seamless communication between services within your cluster.
Harnessing the Power of Kubernetes: Pods and Deployments Demystified
Discover how Kubernetes Pods and Deployments provide powerful tools for managing and scaling applications efficiently within containerized environments.
Effortlessly Set Up Your First Kubernetes Cluster on AWS EKS
Learn how to effortlessly set up your first Kubernetes cluster on AWS EKS with this step-by-step guide, perfect for developers aiming to leverage cloud scalability.