# dmesg
- [Command Function](#section4643204919313)
- [Syntax](#section6553153635)
- [Parameters](#section208971157532)
- [Usage](#section213115219413)
- [Example](#section13736564418)
- [Output](#section194005101413)
## Command Function
This command is used to control the dmesg buffer of the kernel.
## Syntax
dmesg
dmesg \[_-c/-C/-D/-E/-L/-U_\]
dmesg -s \[_size_\]
dmesg -l \[_level_\]
dmesg \> \[_fileA_\]
## Parameters
**Table 1** Parameter description
Parameter
|
Description
|
Value Range
|
-c
|
Prints content in the buffer and clears the buffer.
|
N/A
|
-C
|
Clears the buffer.
|
N/A
|
-D/-E
|
Enables or disables printing to the console.
|
N/A
|
-L/-U
|
Enables or disables printing via the serial port.
|
N/A
|
-s size
|
Sets the size of the buffer.
|
N/A
|
-l level
|
Sets the buffering level.
|
0 - 5
|
> fileA
|
Writes the content in the buffer to a file.
|
N/A
|
## Usage
- This command depends on **LOSCFG\_SHELL\_DMESG**. Before using this command, select **Enable Shell dmesg** on **menuconfig**.
Debug ---\> Enable a Debug Version ---\> Enable Shell ---\> Enable Shell dmesg
- If the parameters are not specified, all content in the buffer is printed.
- The parameters followed by hyphens \(-\) are mutually exclusive.
1. Before writing content to a file, ensure that the file system has been mounted.
2. Disabling the serial port printing will adversely affect the shell. You are advised to set up a connection using Telnet before disabling the serial port.
## Example
Example:
Run **dmesg \> /usr/dmesg.log**.
## Output
**Figure 1** Writing dmesg content to a file
![](figure/writing-dmesg-content-to-a-file.png "writing-dmesg-content-to-a-file")