How to edit root files in /sys (Permission Denied)? I have been trying to change root files in my phone through an app I am developing. The phone I have is a Moto G6, fully rooted. I'm using terminal emulators to run commands on my phone. I've tried "Terminal Emulator for Android" and "Shell Terminal Emulator" apps to try to make my files modifiable.

The commands I've tried to run are as follows:

su
mount -o rw,remount /system


In Terminal Emulator for Android this appears to work because it offers no error message but in Shell Terminal Emulator I'm hit with the following:

"...whatever.../system not user mountable in fstab"


So I went to check if it worked anyway and tried to modify a file in the root browser. The file:

/sys/devices/virtual/android_usb/android0/power/control


The file currently has the permissions set as "rw-r--r--" and filled with the text "auto" and after trying to save the file with the contents "0" instead I'm provided with this big ugly error message:

Error when saving file
=====Description=====
java.io.FileNotFoundException: "...file name..." and then (permission denied)


What I want to know is why I don't have permission to edit these files, afterall my phone is fully rooted and I have granted root access to the text editor.

Any solution or step in the right direction is greatly appreciated.
in Shell Terminal Emulator app I'm hit with the following:
  "...whatever.../system not user mountable in fstab"


toybox mount returns that error when UID isn't 0 i.e. you aren't root.


  tried to modify a file in the root browser. The file:
  /sys/devices/virtual/android_usb/android0/power/control


/system and /sys are two different filesystems. Mounting one R/W won't allow you R/W access to the other. /system is the mount point of a partition which contains Android OS. It can't be mounted R/W without getting root access and without disabling dm-verity. sysfs is Linux kernel's pseudo filesystem which provides information related to hardware stuff and exposes some interfaces to userspace for kernel configuration and tweaking.

sysfs is mounted R/W by default but not every file in this filesystem can be modified. Only some specific values can be written to specific files. The file you are trying to write is related to power management of USB Gadget driver of kernel which is to let the device be in some kind of slave role (device mode), not in USB host role. Possible values for control file are auto and on as per documentation.


  after trying to save the file with the contents "0" instead I'm provided with this big ugly error message


I'm not sure about that Java related error, you can get better help at stackoverflow. However you can get a root shell and do:

~# echo -n on &gt;/sys/devices/virtual/android_usb/android0/power/control


This must work, I've tried that in GUI text editor too. Probably the value 0 you are trying to write isn't a valid value for kernel, except if you are changing something at driver level.

If the purpose is only to edit files for testing which can't be accessed / modified without root, create / edit / delete a file in /data/local. /data doesn't need remounting.