0Pricing
Linux Command Line Mastery · درس

تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها

استكشف سجلات النظام، واستخدم `journalctl`، وطبّق أساليب منهجية لاستكشاف المشكلات المعقدة وإصلاحها.

تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها درس مجاني في Linux Command Line Mastery على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Linux Command Line Mastery، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Linux Command Line Mastery 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Logs Matter

When something goes wrong on a Linux system, logs are your best friend! They are like a digital diary that records events and activities.

System logs help you understand what happened, when it happened, and often, why it happened. This information is crucial for fixing problems and maintaining system health.

The `/var/log` Directory

Traditionally, most system logs are stored in the /var/log directory. You'll find many files here, each typically dedicated to a specific service or type of event.

  • auth.log: Records authentication attempts.
  • syslog: General system activity messages.
  • kern.log: Messages from the Linux kernel.

It's a treasure trove of information, but navigating it can be complex.

Viewing Classic Logs

For older log files or those not managed by systemd, you can use basic commands like cat, less, or tail to view their contents.

tail -f is especially useful for watching logs in real-time as new entries are added.

Try viewing the end of the syslog file (if available on your system):

tail /var/log/syslog

Modern Logging with `journalctl`

Modern Linux systems often use systemd, which includes its own logging system called the Journal. The command-line tool to interact with this journal is journalctl.

journalctl provides a centralized way to access logs from the kernel, services, and applications, making troubleshooting much more efficient than sifting through many files.

Your First `journalctl` Command

Running journalctl without any arguments will display all log messages collected by the systemd journal, starting from the oldest available entry.

It's a lot of information! You can scroll with arrow keys, Page Up/Down, or 'q' to quit. This is your comprehensive system log:

journalctl

Narrowing Down Log Entries

The real power of journalctl comes from its filtering capabilities. You can specify exactly what you want to see:

  • -u <unit>: Show logs for a specific systemd unit (e.g., a service like nginx or sshd).
  • -b: Show logs from the current boot.
  • --since "YYYY-MM-DD HH:MM:SS": Filter by a specific time or date.

Let's check logs specifically for the `ssh` service (sshd unit), if it's running:

journalctl -u sshd

Watching Logs in Real-time

Just like tail -f, journalctl can also display new log entries as they happen. This is incredibly useful when you're trying to debug an issue in real-time, for example, when starting a service.

Use the -f (follow) option to continuously monitor the journal for new messages:

journalctl -f

A Plan for Problem Solving

Effective troubleshooting isn't just about looking at logs; it's about having a systematic approach. Here's a common methodology:

  • Observe: What are the symptoms? What is failing or acting strangely?
  • Define: Clearly state the problem. What exactly is not working as expected?
  • Isolate: Determine where the problem might be (e.g., network, specific service, configuration, hardware).
  • Test: Propose a solution based on your findings and test it.
  • Document: Record what you did, what worked, and what didn't.

Where to Start Looking

When a problem arises, start with these basic checks:

  • Recent Changes: Did anything change recently? New software installed, configuration edits, system updates?
  • Service Status: Is the relevant service running? (Use systemctl status <service>).
  • Resource Usage: Are you out of disk space, memory, or CPU? (df -h, free -h, top).
  • Relevant Logs: Use journalctl -u <service> -b to check logs for the affected service since the last boot.

`journalctl` Filtering Challenge

You need to find log entries related to the nginx web server that occurred since yesterday. Which journalctl command(s) would be most appropriate?

Logs & Troubleshooting Recap

Great job! You've learned how critical system logs are for diagnosing issues on Linux.

We explored the traditional /var/log directory and, more importantly, mastered journalctl for viewing, filtering, and following modern systemd logs.

Remember to combine these powerful tools with a systematic troubleshooting approach to efficiently identify and resolve complex system problems!

الأسئلة الشائعة

هل درس «تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها» مجاني؟

نعم — نص درس «تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Linux Command Line Mastery، انتقل إلى CoddyKit PRO. تتضمن دورة Linux Command Line Mastery 4 دروس في المجموع.

ماذا ستتعلم في «تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها»؟

استكشف سجلات النظام، واستخدم `journalctl`، وطبّق أساليب منهجية لاستكشاف المشكلات المعقدة وإصلاحها. تتمرن على Linux Command Line Mastery مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Linux Command Line Mastery؟

لا تُشترط خبرة سابقة. Linux Command Line Mastery على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Linux Command Line Mastery هذا؟

نعم. كل درس في Linux Command Line Mastery يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. مراقبة إدخال/إخراج القرص: `iostat` و`iotop`
  2. أدوات أداء الذاكرة ووحدة المعالجة المركزية
  3. تقنيات متقدمة للتسجيل واستكشاف الأخطاء وإصلاحها
  4. تتبّع استدعاءات النظام باستخدام strace وltrace
← العودة إلى Linux Command Line Mastery