How to run `chmod` command on boot on Android 10?
echo "chmod 666 /dev/diag" &gt;&gt; /system/etc/init/cameraserver.rc won't work. You need to provide an init trigger as well. For instance:

~# echo "on boot" &gt;/etc/init/dev_diag_chmod.rc
~# echo "    chmod 666 /dev/diag" &gt;&gt;/etc/init/dev_diag_chmod.rc
~# chown 0.0 /etc/init/dev_diag_chmod.rc
~# chmod 0644 /etc/init/dev_diag_chmod.rc
~# chcon u:object_r:system_file:s0 /etc/init/dev_diag_chmod.rc


But even simple approach is to edit the ueventd.rc file (which is read and executed by Android's device manager) provided by vendor (since /dev/diag is a hardware specific interface) which creates the device node. Replace the relevant statement inside that file to set whatever permission mode, owner and group you want. E.g. you can replace:

/dev/diag    0660    system    system


With:

/dev/diag    0666    system    system