0Pricing
Linux Command Line Mastery · درس

تتبّع استدعاءات النظام باستخدام strace وltrace

تعمّق في استكشاف الأخطاء بتتبّع استدعاءات النظام والمكتبات التي تجريها العملية، لتعرف بدقة أين تتوقف أو تفشل

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

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

When Metrics Are Not Enough

CPU, memory, and I/O tools tell you that something is slow. To learn why, you trace what a process actually asks the kernel to do. strace and ltrace open that window.

What strace Shows

strace records every system call: file opens, reads, network sends, and their return values, including errors.

strace ls /tmp

Attaching to a Running Process

Use -p PID to trace something already running, such as a stuck service.

sudo strace -p 4567

Filtering Specific Calls

-e trace= limits output to calls you care about, e.g. only file-related ones.

strace -e trace=openat,read,write cat /etc/hostname

Finding Missing Files

A classic use: see which file a program fails to open. Look for ENOENT (no such file) in the output.

strace -e trace=openat myapp 2>&1 | grep ENOENT

Summarizing with -c

-c prints a profile: which syscalls consumed the most time and how often each was called.

strace -c ls -R /usr/share

Timing Calls

-T shows how long each syscall took, and -t adds timestamps, pinpointing where a process blocks.

strace -T -e trace=read myapp

Following Child Processes

-f follows forks so you trace child processes too, essential for servers that spawn workers.

strace -f -p 4567

Saving Output to a File

Traces are noisy; -o writes them to a file you can grep later without cluttering the terminal.

strace -o trace.log -f myapp

ltrace for Library Calls

While strace shows kernel calls, ltrace shows library calls like malloc or strcmp, useful for logic-level debugging.

ltrace ./myprogram

A Troubleshooting Recipe

When a service hangs: attach with strace -f -p, watch for a syscall that never returns (often a blocked read or connect), and you have found the stall.

Quick Check

What kind of activity does strace primarily reveal?

Recap

You can now trace a process at the syscall level:

  • strace cmd or -p PID to attach
  • -e trace= filters, -c profiles, -T/-t time
  • -f follows children, -o saves output
  • ltrace shows library calls

Watch for errors like ENOENT or a syscall that never returns.

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

هل درس «تتبّع استدعاءات النظام باستخدام strace وltrace» مجاني؟

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

ماذا ستتعلم في «تتبّع استدعاءات النظام باستخدام strace وltrace»؟

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

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

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

كم من الوقت يستغرق درس «تتبّع استدعاءات النظام باستخدام strace وltrace»؟

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

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

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

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

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