dmesg Command in Linux

Learn via video courses
Topics Covered

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Overview

In the heart of every Linux system, the kernel is constantly interacting with hardware, processes, and system services. A crucial tool for understanding these interactions is the dmesg command in Linux. It allows users to peek into the kernel's activities by displaying its message buffer, often used for troubleshooting hardware issues and system errors.

Syntax of dmesg Command in Linux

The basic syntax of the dmesg command in Linux is as follows:

Where:

  • dmesg: This is the command itself, which triggers the display of the kernel's message buffer.
  • [options]: This is where you specify options that modify the behavior of the command. These options are optional and can be combined as needed.
Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Options in dmesg command in Linux

  1. -C, --clear: Clears the kernel ring buffer.

    For example -

    This command does not produce any output as it's used to clear the kernel ring buffer. It requires root privileges.

  2. -w, --follow: Displays the messages in real-time as they appear in the kernel ring buffer.

    For example -

    This command does not produce any output initially. Instead, it will keep the terminal open and print new kernel messages as they occur.

  3. -T, --ctime: Print human-readable timestamps.

    For example -

    Output:

    This command prints the kernel messages with human-readable timestamps instead of the default time since the system boot.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Displaying the kernel messages.:

    Output:

    Explanation: This command displays the kernel messages. The numbers in the brackets are the timestamp, showing time since the system booted.

  • Filtering kernel messages by a specific facility like 'memory'.:

    Output:

    Explanation: This command filters the kernel messages to only show those related to memory.

Tips

  • The dmesg command requires root privileges to access some of the functionalities. Consider using 'sudo' when appropriate.

  • The output of dmesg can be quite extensive. It's often helpful to pipe the output to 'less' or 'grep' to filter and navigate through the messages.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of dmesg Command in Linux

  • Using the --level option to filter messages by priority.:

    Output:

    Explanation: This command displays only the error and warning messages from the kernel ring buffer. The --level option can take different values like emerg, alert, crit, err, warn, notice, info, and debug.

  • Displaying the kernel messages related to a specific device like 'eth0'.:

    Output:

    Explanation: This command filters the kernel messages to only show those related to the 'eth0' network interface.

  • Saving the kernel messages to a file.:

    Explanation: This command does not produce any output on the terminal. Instead, it saves the kernel messages to a file named 'kernel_messages.log'.

Conclusion

  • The dmesg command in Linux is a powerful tool for viewing and understanding the activities of the Linux kernel.

  • It's most commonly used for troubleshooting hardware issues and system errors.

  • The output of dmesg can be filtered using various options and by piping it to other commands like 'grep'.

  • Some functionalities of dmesg require root privileges.