function::kernel_char - Linux


The kernel_char command provides access to kernel characters, namely, devices and pseudo-devices. With this command, users can read, write, and manipulate data in the kernel space, allowing for fine-grained control over hardware and system behavior. It is highly useful for debugging, device testing, and advanced system administration tasks.


kernel_char [-a] [-l] [-r] [-w] [-s <size>] [-p <pos>] [-S] [-f] [-t] [-g] <device> <>


  • -a: Append to the end of the file.
  • -l: List all available devices.
  • -r: Read from the device.
  • -w: Write to the device.
  • -s <size>: Specify the size of the read/write operation in bytes. Default: 1.
  • -p <pos>: Set the read/write position. Default: 0.
  • -S: Display data in ASCII format.
  • -f: Flush data to disk.
  • -t: Keep the device open for multiple operations.
  • -g: Return the global mode of the device.


Read 10 bytes from /dev/input/mouse:

kernel_char -r -s 10 /dev/input/mouse

Write "Hello World" to /dev/ttyS0:

kernel_char -w /dev/ttyS0 "Hello World"

List all available devices:

kernel_char -l

Common Issues

Permission Denied: Ensure that you have sufficient permissions to access the device.

Device Not Found: Check if the device is properly connected and recognized by the system.

Incorrect Data Format: Use the -S option to display data in ASCII format for easier readability.


kernel_char can be combined with other tools for advanced tasks:

  • grep: Filter data from the device.
  • awk: Parse and process data.
  • sed: Modify or edit data.

Related Commands

  • dd: Reading and writing raw data blocks.
  • cat: Reading and displaying file contents.
  • /proc/devices: Provides information about kernel devices.