Home·Terminal commands

dmesg

Processes and system

Usage

sudo dmesg -T | tail

Reads the kernel ring buffer, the first place to look after a disk or USB problem; it is a fixed-size buffer so older lines are already gone, and most distributions now require root (macOS uses `log show`).

Common flags

FlagMeaning
-THuman-readable timestamps instead of seconds since boot.
-wFollow new kernel messages as they appear.
-l err,warnFilter by level.
-HPaged, colourised, relative-time output.
--since "5 min ago"Time-bounded output (newer util-linux).

Examples

sudo dmesg -T | tail -50

Read what the kernel said about a disk or USB device just now.

dmesg -w

Watch live while you plug something in.

log show --last 10m

The macOS equivalent; its dmesg exists but shows almost nothing.

What is running and what is eating the machine. Identifying it comes before killing it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does dmesg do?

Reads the kernel ring buffer, the first place to look after a disk or USB problem; it is a fixed-size buffer so older lines are already gone, and most distributions now require root (macOS uses `log show`).

Q. How do I type it?

sudo dmesg -T | tail — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man dmesg. This command sits under Processes and system.

Related commands

man page: man dmesg