0
0
Linux CLIscripting~20 mins

dmesg for kernel messages in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kernel Message Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What does this dmesg command output?
You run the command dmesg | grep usb on a Linux system. What kind of output should you expect?
Linux CLI
dmesg | grep usb
ALines containing kernel messages related to USB devices, such as device connection or disconnection events.
BA list of all running processes related to USB devices.
CThe current USB device configuration settings in a table format.
DA summary of all network interfaces and their statuses.
Attempts:
2 left
💡 Hint
Think about what dmesg shows and what grep does when filtering for 'usb'.
🧠 Conceptual
intermediate
2:00remaining
Why use dmesg instead of checking /var/log/messages for kernel logs?
Which reason best explains why you might prefer using dmesg to view kernel messages instead of reading the /var/log/messages file?
Admesg requires root privileges, while /var/log/messages does not.
B/var/log/messages only contains user application logs, not kernel messages.
Cdmesg shows the current kernel ring buffer directly, providing real-time kernel messages without delay.
D/var/log/messages is only updated once per day, so it never shows recent kernel events.
Attempts:
2 left
💡 Hint
Think about how dmesg accesses kernel messages compared to log files.
📝 Syntax
advanced
2:00remaining
Which command correctly shows the last 10 kernel messages using dmesg?
You want to see only the last 10 lines of kernel messages using dmesg. Which command will do this correctly?
Admesg -n 10
Bdmesg tail 10
Cdmesg --last 10
Ddmesg | tail -10
Attempts:
2 left
💡 Hint
Remember that dmesg outputs all messages and you can pipe it to other commands.
🔧 Debug
advanced
2:00remaining
What error occurs with this dmesg command?
You run the command dmesg --follow to watch kernel messages live, but it returns an error. What is the likely cause?
Linux CLI
dmesg --follow
AError: unrecognized option '--follow' because the dmesg version does not support this flag.
BPermission denied error because dmesg requires root to run.
CSyntax error due to missing argument after '--follow'.
DNo error; the command runs and shows live kernel messages.
Attempts:
2 left
💡 Hint
Check if the dmesg version supports the option you used.
🚀 Application
expert
3:00remaining
How to filter dmesg output for kernel warnings and save to a file?
You want to save all kernel warning messages from dmesg to a file named warnings.log. Which command does this correctly?
Admesg --level=warning > warnings.log
Bdmesg | grep -i warning > warnings.log
Cdmesg | filter warning > warnings.log
Ddmesg -w > warnings.log
Attempts:
2 left
💡 Hint
Use grep to filter text output for keywords.