Hinson's blog

𝕰𝖝𝖈𝖊𝖑𝖑𝖊𝖓𝖈𝖊 𝖎𝖓 𝖈𝖑𝖔𝖚𝖉 𝖆𝖗𝖈𝖍𝖎𝖙𝖊𝖈𝖙𝖚𝖗𝖊 𝖆𝖓𝖉 𝖘𝖊𝖈𝖚𝖗𝖎𝖙𝖞 𝖉𝖔𝖒𝖆𝖎𝖓𝖘 𝖎𝖘 𝖙𝖍𝖊 𝖊𝖙𝖊𝖗𝖓𝖆𝖑 𝖕𝖚𝖗𝖘𝖚𝖎𝖙 𝖔𝖋 𝖒𝖞 𝖕𝖗𝖔𝖋𝖊𝖘𝖘𝖎𝖔𝖓𝖆𝖑 𝖌𝖗𝖔𝖜𝖙𝖍

Mastering Resource Monitoring: The Ultimate Linux Cheat Sheet for My Reference

Spread the love

1. CPU and Memory Usage

  • top
    • -d: Specify the delay time between screen updates.
    • -u <user>: Display processes belonging to a specific user.
  • htop
    • F6: Sort by various criteria including CPU, memory.
    • F5: Toggle tree view.
  • vmstat
    • 1: Display statistics every second.
    • -s: Show event counters and memory statistics.

2. Disk Usage

  • df
    • -h: Human-readable format, showing sizes in KB, MB, or GB.
    • -T: Include filesystem type in the output.
  • du
    • -h: Human-readable format.
    • -a: Include all files, not just directories.
  • iostat
    • -x: Display extended statistics.
    • -d: Display disk utilization only.

3. Network

  • netstat
    • -tuln: Display TCP/UDP listening ports.
    • -p: Show the PID and name of the program to which each socket belongs.
  • ss
    • -t -a: Display all TCP sockets.
    • -u -a: Display all UDP sockets.
  • iftop
    • -i <interface>: Specify network interface.
    • -n: Do not resolve hostnames (faster display).
  • nload
    • -m: Display multiple devices at once.
    • -t <interval>: Set the refresh interval in milliseconds.
  • ping
    • -c <count>: Number of echo requests to send.
    • -i <interval>: Interval between sending each packet.

4. Process Monitoring

  • ps
    • -aux: Show all processes for all users.
    • -eH or --forest: Display processes in a hierarchy.
  • pstree
    • -p: Show PIDs.
    • -u: Show usernames.

5. System Activity Reporter (sar)

  • -r: Report memory utilization.
  • -n DEV: Report network statistics.
  • -d: Report disk activity.
  • -u: Report CPU utilization.

6. Performance Analysis

  • perf
    • stat: Gather performance counters for a command.
    • record: Record events for later analysis.
    • report: Analyze and report performance data.
  • strace
    • -f: Trace child processes.
    • -e trace=<syscall>: Trace specified system calls.

7. Monitoring Files and Directories

  • inotifywait
    • -m: Monitor events indefinitely instead of exiting after the first event.
    • -r: Recursively watch all directories and subdirectories.
  • inotifywatch
    • -t <seconds>: Run for a specified number of seconds before exiting.
    • -r: Recursively watch all directories and subdirectories.

Leave a Reply

Your email address will not be published. Required fields are marked *