الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

dmesg

Show the kernel messages (the kernel ring buffer): hardware found, drivers loaded, disk and memory errors.

المستوى
امتحان RHCSA
المجموعة
النواة والعتاد
يحتاج root
للتغييرات
الحزمة
util-linux

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

The kernel writes its messages into a ring buffer in memory. dmesg prints it: from the first boot messages to new events, like a USB stick being plugged in or a disk error. Times are seconds since boot; -T makes them readable.

On RHEL, normal users may be blocked (kernel.dmesg_restrict = 1); root can always read it. journalctl -k shows the same messages and also those of earlier boots.

طريقة الكتابة

dmesg [OPTION]...

الخيارات 30

الأكثر استخدامًا

Filter

-l, --level LIST
Only these levels: emerg, alert, crit, err, warn, notice, info, debug.
-f, --facility LIST
Only these facilities: kern, user, daemon …
-k, --kernel
Only kernel messages.
-u, --userspace
Only user-space messages.
--since TIME, --until TIME
Only messages in this time window.

Time and format

-T, --ctime
Human-readable time stamps.
-H, --human
Human output with colors and a pager.
-e, --reltime
Local time and time difference.
-d, --show-delta
Time since the previous message.
-t, --notime
No time stamps.
--time-format FORMAT
ctime, notime, delta, reltime, iso, raw.
-x, --decode
Show facility and level as words.
-r, --raw
Raw messages with level prefixes.
-J, --json
JSON output.
-L, --color[=WHEN]
Colors.
-p, --force-prefix
Prefix every line of multi-line messages.
--noescape
Do not escape unprintable characters.
-P, --nopager
No pager.

Follow

-w, --follow
Wait for new messages (like tail -f).
-W, --follow-new
Only new messages.

Buffer

-c, --read-clear
Print and clear the buffer (root).
-C, --clear
Clear the buffer (root).
-s, --buffer-size SIZE
Buffer size to read.
-S, --syslog
Use the syslog interface instead of /dev/kmsg.
-F, --file FILE
Read from a file.

Console

-n, --console-level LEVEL
Messages up to this level go to the console.
-D, --console-off
Stop messages on the console.
-E, --console-on
Messages on the console again.
-h, --help
Show help.
-V, --version
Show the version.

أمثلة 11

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1All kernel messages

    dmesg | less

    From the boot until now.

  2. 2Readable times

    dmesg -T | tail
    [Sun Oct 25 10:31:07 2026] sd 2:0:0:0: [sdc] Attached SCSI removable disk

    When did it happen?

  3. 3Errors and warnings only

    dmesg -T --level=err,warn

    First check for hardware trouble.

  4. 4Watch live

    dmesg -wT

    Plug in a device and see the messages.

  5. 5Disk errors (I/O)

    dmesg -T | grep -iE 'i/o error|blk_update_request|ata[0-9].*error'

    A failing disk or cable.

  6. 6Memory killer

    dmesg -T | grep -i 'out of memory'

    Which process the OOM killer killed.

  7. 7Find the device name of a new USB disk

    dmesg -T | tail -20 | grep -E 'sd[a-z]'

    Then use lsblk.

  8. 8Firewall drops logged by the kernel (security)

    dmesg -T | grep -i 'filter_'

    Shows packets that were logged and dropped.

  9. 9Segfaults of programs

    dmesg -T | grep -i segfault

    Crashes and possible exploit attempts.

  10. 10Check if users may read it (hardening)

    sysctl kernel.dmesg_restrict
    kernel.dmesg_restrict = 1

    1 = only root (hides kernel addresses from attackers).

  11. 11Earlier boots

    journalctl -k -b -1

    dmesg only shows the current boot.

رموز الخروج

0Done.
1Error.