0Pricing
Linux Command Line Mastery · Lektion

Tools für Speicher- und CPU-Leistung

Verwenden Sie Tools wie `vmstat`, `sar` und `mpstat`, um leistungsbezogene Probleme bei CPU und Arbeitsspeicher zu diagnostizieren.

Tools für Speicher- und CPU-Leistung ist eine kostenlose Linux Command Line Mastery-Lektion auf CoddyKit. Dies ist Lektion 2 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Linux Command Line Mastery-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Diagnose Performance Issues

Understanding system performance is key to troubleshooting slow applications or an unresponsive server. CPU and memory are often the first resources to check.

In this lesson, we'll explore powerful command-line tools to monitor and diagnose issues related to your system's CPU and memory usage.

Meet `vmstat`

The vmstat (virtual memory statistics) command provides a quick, real-time snapshot of your system's activity. It reports on processes, memory, paging, block I/O, traps, and CPU activity.

It's excellent for observing current system behavior and identifying immediate bottlenecks.

`vmstat` Memory Overview

Let's run vmstat 1 1 to see a single report, then we'll break down the memory-related output. This command shows a report every 1 second, for 1 iteration.

  • swpd: amount of virtual memory used.
  • free: amount of idle memory.
  • buff: memory used as buffers.
  • cache: memory used as cache.
vmstat 1 1

`vmstat` CPU Details

Now, let's look at the CPU section of vmstat. Run the command again if you like, and focus on the 'cpu' columns:

  • us (user): time spent running non-kernel code.
  • sy (system): time spent running kernel code.
  • id (idle): time spent idle.
  • wa (wait): time spent waiting for I/O.

High wa often indicates disk bottlenecks.

vmstat 1 1

Introducing `sar`

The sar (System Activity Reporter) command is part of the sysstat package. Unlike vmstat, sar can collect and report historical system activity data.

This makes it invaluable for long-term analysis, identifying trends, and diagnosing intermittent problems that might not be visible with real-time tools.

`sar` for CPU Usage

To view CPU utilization with sar, we use the -u option. Run sar -u 1 1 to get a single report.

  • %user: CPU usage by user-level applications.
  • %system: CPU usage by kernel-level tasks.
  • %iowait: Time CPU spent waiting for I/O.
  • %idle: Time CPU was idle.
sar -u 1 1

`sar` for Memory Usage

To get detailed memory utilization reports with sar, use the -r option. Try sar -r 1 1.

  • kbmemfree: Amount of free memory.
  • kbmemused: Amount of used memory.
  • %memused: Percentage of used memory.
  • kbbuffers: Memory used by kernel buffers.
  • kbcached: Memory used by page cache.
sar -r 1 1

Understanding `mpstat`

The mpstat (multi-processor statistics) command is also part of the sysstat package. Its main advantage is providing per-processor or per-core CPU activity.

This is crucial for systems with multiple CPU cores, as it helps identify if a specific core is overloaded while others are idle.

`mpstat` Per-Core Activity

To see statistics for all individual CPU cores, use mpstat -P ALL 1 1. You'll see a separate line for each core (CPU 0, CPU 1, etc.) and an 'all' line for the average.

This helps pinpoint if a single-threaded application is maxing out one core, even if overall CPU usage seems low.

mpstat -P ALL 1 1

Performance Tool Check

Which of the following statements about Linux performance tools are TRUE?

Recap: CPU & Memory Tools

In this lesson, you learned about three essential tools for monitoring CPU and memory performance:

  • vmstat: For real-time system activity snapshots.
  • sar: For collecting and reporting historical system activity data.
  • mpstat: For detailed per-processor/per-core CPU usage.

Mastering these commands will significantly boost your ability to diagnose and troubleshoot Linux system performance issues.

Häufig gestellte Fragen

Ist die Lektion „Tools für Speicher- und CPU-Leistung“ kostenlos?

Ja — der vollständige Text von „Tools für Speicher- und CPU-Leistung“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Linux Command Line Mastery-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Tools für Speicher- und CPU-Leistung“?

Verwenden Sie Tools wie `vmstat`, `sar` und `mpstat`, um leistungsbezogene Probleme bei CPU und Arbeitsspeicher zu diagnostizieren. Du übst Linux Command Line Mastery mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Linux Command Line Mastery zu starten?

Keine Vorkenntnisse erforderlich. Linux Command Line Mastery auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 2 von 4.

Wie lange dauert die Lektion „Tools für Speicher- und CPU-Leistung“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Linux Command Line Mastery-Lektion Code schreiben und ausführen?

Ja. Jede Linux Command Line Mastery-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Überwachung der Festplatten-E/A: `iostat`, `iotop`
  2. Tools für Speicher- und CPU-Leistung
  3. Fortgeschrittene Logging- und Fehlerbehebungstechniken
  4. Systemaufrufe mit strace und ltrace nachverfolgen
← Zurück zu Linux Command Line Mastery