Help! Renamed /system/bin/sh to sh.old.bak, lost root, can't rename, no nandroid backup I did something incredibly stupid today.   I renamed /system/bin/sh  to /system/bin/sh.old.bak on my rooted Huawei y536a1 running 4.4.3 KK.  I was going to install a app I thought might overwrite it and wanted a backup. I intended to copy it to another location in the path or link it, then rename in bin. In my haste,  I simply renamed it and couldn't install app w/o shell,  lost root,  thus eliminating any easy method I know of to fix.  I rooted with kingroot (not kingo)  because I currently do not have a computer.  I have no system backup,  foolish,  I know. I do have the original factory  .img file,  a pre-rooted .img file, (the only way to properly root and install a recovery) twrp recovery and a code to unlock the bootloader.   Since I didn't have a computer I used kingroot.  The phone is still functional.   Unfortunately I don't know what to do now. I have limited linux knowledge (obviously).  I am afraid to reboot,  not knowing what will happen. I can get access to a computer. The file needs to be renamed,  but I lost write access to the system. Is there anyway to use adb to rename or push another file on there,  or fix by rebooting into recovery?  I would prefer a solution the wouldn't wipe my phone, but I realize my options are quite limited. I don't even know if a factory reset or flashing either of the images will work. Any help/advice is greatly appreciated.
I'll now guide you through the procedure of writing a custom flashable ZIP, for the purpose of renaming your sh.old.bak. To begin, create the following tree of folders:

/META-INF/com/google/android


Once you created them, move to the android folder, and create the following new files. Make sure that they don't have any extension at their end:


updater-script
update-binary


Leave the first one blank, and proceed by editing the update-binary as follows:

#!/sbin/sh
mount /system
mount -o remount,rw /system
mv /system/bin/sh.old.bak /system/bin/sh
umount /system


Save this content (in the update-binary), open your favourite zipping tool, and create a compressed archive out of the META-INF folder. Its content should be automatically included. Make sure that the archive type is set to ZIP, and select the lowest possible compression level.

Finally, flash this script to your device with:

fastboot update name_of_your_zip.zip


As guessable, the third parameter should be the name (and path) of the ZIP you created. In short, the ZIP should mount the /system partition in read-write mode, rename your sh.old.bak to sh, and unmount the /system partition.