🚀 Master Linux Debugging with dmesg & journalctl – Essential Commands for Troubleshooting!
🚀 Master Linux Debugging with dmesg & journalctl – Essential Commands for Troubleshooting!
=================================================
1️. dmesg - Kernel Logs for Hardware & System Issues
=================================================
✅ What It Does?
dmesg (display message) shows kernel logs, including hardware issues, driver failures, disk errors, and boot messages.
✅ Use Cases:
✔️ Diagnosing boot issues
✔️ Identifying disk I/O errors
✔️ Checking kernel panics
✔️ Debugging network and device issues
🛠 dmesg Commands for Troubleshooting:
-----------------------------------------------
1. 🔹 View the latest kernel messages:
dmesg | tail -50
2. 🔹 Filter messages by time (useful for debugging a past issue):
dmesg --since "10 minutes ago"
3. 🔹 Check for hardware errors (disks, RAM, etc.):
dmesg | grep -i "error\|fail\|warn"
4. 🔹 Check for disk failures:
dmesg | grep -i "ext4\|xfs\|sda\|nvme"
5. 🔹Check if a network interface (e.g., eth0) is failing:
dmesg | grep -i eth0
6. 🔹Check CPU or memory errors:
dmesg | grep -i "CPU\|memory\|OOM"
7. 🔹Monitor logs in real-time (like tail -f):
dmesg -w
=================================================
2️. journalctl - Systemd Logs for Services & Authentication
=================================================
✅ What It Does?
journalctl provides detailed logs of system events, user logins, authentication failures, and systemd service failures.
✅ Use Cases:
✔️ Checking failed services
✔️ Investigating login failures
✔️ Debugging system crashes
✔️ Viewing specific service logs
🛠 journalctl Commands for Troubleshooting:
--------------------------------------------------
1. 🔹 View system logs (all logs from boot time)
journalctl -n 50
2. 🔹 Show logs in real-time (like tail -f)
journalctl -f
3. 🔹 Check logs from the last system boot
journalctl -b
4. 🔹 Check failed systemd services
systemctl --failed
journalctl -p 3 -xb
5. 🔹 View logs for a specific service (e.g., Nginx)
journalctl -u nginx --since "1 hour ago"
6. 🔹 Find user login attempts & authentication failures
journalctl _UID=1000 | grep "authentication failure"
7. 🔹 View logs from a specific time
journalctl --since "2024-02-03 12:00:00" --until "2024-02-03 15:00:00"
=================================================
Example: Debugging a Slow Server
=================================================
🔍 Step 1: Check CPU Usage
top -o %CPU
🔍 Step 2: Check Disk I/O Issues
iostat -x 1
🔍 Step 3: Check for Disk Errors
dmesg | grep -i "I/O error\|ext4\|xfs"
🔍 Step 4: Check if a Process is Being Killed
journalctl -k | grep -i "killed process"
=================================================
Видео 🚀 Master Linux Debugging with dmesg & journalctl – Essential Commands for Troubleshooting! канала SubbuTechTutorials
=================================================
1️. dmesg - Kernel Logs for Hardware & System Issues
=================================================
✅ What It Does?
dmesg (display message) shows kernel logs, including hardware issues, driver failures, disk errors, and boot messages.
✅ Use Cases:
✔️ Diagnosing boot issues
✔️ Identifying disk I/O errors
✔️ Checking kernel panics
✔️ Debugging network and device issues
🛠 dmesg Commands for Troubleshooting:
-----------------------------------------------
1. 🔹 View the latest kernel messages:
dmesg | tail -50
2. 🔹 Filter messages by time (useful for debugging a past issue):
dmesg --since "10 minutes ago"
3. 🔹 Check for hardware errors (disks, RAM, etc.):
dmesg | grep -i "error\|fail\|warn"
4. 🔹 Check for disk failures:
dmesg | grep -i "ext4\|xfs\|sda\|nvme"
5. 🔹Check if a network interface (e.g., eth0) is failing:
dmesg | grep -i eth0
6. 🔹Check CPU or memory errors:
dmesg | grep -i "CPU\|memory\|OOM"
7. 🔹Monitor logs in real-time (like tail -f):
dmesg -w
=================================================
2️. journalctl - Systemd Logs for Services & Authentication
=================================================
✅ What It Does?
journalctl provides detailed logs of system events, user logins, authentication failures, and systemd service failures.
✅ Use Cases:
✔️ Checking failed services
✔️ Investigating login failures
✔️ Debugging system crashes
✔️ Viewing specific service logs
🛠 journalctl Commands for Troubleshooting:
--------------------------------------------------
1. 🔹 View system logs (all logs from boot time)
journalctl -n 50
2. 🔹 Show logs in real-time (like tail -f)
journalctl -f
3. 🔹 Check logs from the last system boot
journalctl -b
4. 🔹 Check failed systemd services
systemctl --failed
journalctl -p 3 -xb
5. 🔹 View logs for a specific service (e.g., Nginx)
journalctl -u nginx --since "1 hour ago"
6. 🔹 Find user login attempts & authentication failures
journalctl _UID=1000 | grep "authentication failure"
7. 🔹 View logs from a specific time
journalctl --since "2024-02-03 12:00:00" --until "2024-02-03 15:00:00"
=================================================
Example: Debugging a Slow Server
=================================================
🔍 Step 1: Check CPU Usage
top -o %CPU
🔍 Step 2: Check Disk I/O Issues
iostat -x 1
🔍 Step 3: Check for Disk Errors
dmesg | grep -i "I/O error\|ext4\|xfs"
🔍 Step 4: Check if a Process is Being Killed
journalctl -k | grep -i "killed process"
=================================================
Видео 🚀 Master Linux Debugging with dmesg & journalctl – Essential Commands for Troubleshooting! канала SubbuTechTutorials
Комментарии отсутствуют
Информация о видео
3 февраля 2025 г. 23:49:05
00:00:46
Другие видео канала