Skip to content

Instantly share code, notes, and snippets.

@maxisandoval37
Last active April 6, 2023 16:14
Show Gist options
  • Save maxisandoval37/441856056d8e5765aadb0af9051d851e to your computer and use it in GitHub Desktop.
Save maxisandoval37/441856056d8e5765aadb0af9051d851e to your computer and use it in GitHub Desktop.
COMANDOS DRIVERS/MODULOS LINUX
##############INSTALAR HEADERS##############
uname -r
apt search linux-headers-$(uname -r)
##############IMPLEMENTACIÓN###############
//Compilar .c
make clean & make;
//Cargar modulo compilado
sudo insmod ./batman.ko
//listar modulo creado
lsmod | grep batman
//registrar dispositivo
cat /proc/modules | grep batman
//Ver logs del kernel para ver major number
dmesg | grep batman
//Crear archivo de dispositivo
sudo rmmod /dev/batman (opcional)
sudo mknod /dev/batman c ${major_number} 0
//ver major number
ls /dev -lha | grep batman
//Asignar permisos
sudo chmod 666 /dev/batman
//Escribir
sudo echo "hola" > /dev/batman
//Leer
cat /dev/batman
########################################
CREAR ARCHIVO
touch nombre_del_archivo
---
VER DEVICES Y MAJOR NUMBER
cd /dev & ls -l sd*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment