How To Change File Permissions Through ADB

Gizbeat has come across a situation where a chinaphonearena user is soft-bricked and can’t boot into Android. I believe this is due to the permission settings on the build.prop file.

He can still boot into recovery and is already rooted. So here’s a good chance to write a tutorial on how to change file permissions through ADB should the need arise.

The tutorial will cover this specific situation of doing it through recovery, but the basic premise and commands are the same, so you can do it while you’re booted as well (enable USB debugging if you’re booted already).

Also we’ll be changing the permissions in /system, for which root is required. Changing the permissions of non-system files wouldn’t require root access.

I’ll also just mention that if you can boot into Android, the process is much simpler and can be done with ES Explorer or a similar app.

What you’ll need:

What to Do:

  1. Install the PDAnet MTK6589 ADB VCOM drivers
  2. Extract MTK Droid Tools and run it
  3. Boot into recovery by holding Vol-UP and the power button at the same time
  4. Connect your phone to PC via USB
  5. Wait a few seconds and you should see your phone’s info come up on MTK Droid Tools
  6. In the bottom right corner, you’ll see ‘ADB Terminal’. Click it. A small black program window will open.
  7. At the prompt, type ‘adb shell’. You should now see either a ‘$’ or a ‘#’. The # means you’re rooted.
  8. Type ‘cd system’. You should now see ‘/system #’ (SEE NOTES)
  9. Type ‘chmod 644 build.prop’ (SEE NOTES)
  10. Reset
  • ‘cd’ stands for ‘change directory’. Replace inside the ‘<>’ with whatever directory you need to be in. Typing ‘ls’ at any point will show you where you currently are at in the phone’s file system and a list of folders and files at your current location. In this particular instance, we need to change a system file, so we type ‘cd system’ to change the directory to /system. Remember this depends where currently are. For example if we’re already navigated to ‘/android/data’ and type ‘cd system’ it will return an error.
  • This will depend on what file you want to modify. ‘chmod’ is the command. The number following it is the permission code. Then comes the name of the file you want to modify.
 
         U   G   W
        rwx rwx rwx     chmod 777 filename      
        rwx rwx r-x     chmod 775 filename
        rwx r-x r-x     chmod 755 filename
        rw- rw- r--     chmod 664 filename
        rw- r-- r--     chmod 644 filename

        U = User 
        G = Group 
        W = World

        r = Readable
        w = writable
        x = executable 
        - = no permission

Comments

2 responses to “How To Change File Permissions Through ADB”

  1. Chris Avatar
    Chris

    I have tested it on mtk6582 device with android 4.4.2 after replacing
    the recovery.
    Changing build.prop from 0644 to 0646 brick the phone.
    Unrolling the file permission unbrick the phone.
    It stopps after the bootlogo loading but before making logo
    animation.

  2. Garry Garrett Avatar
    Garry Garrett

    I found your page because I’m searching for a way to fix permissions on my non-system files.

    I have a directory on my SD card, where I have some text files. They were created by a couple of different text editor apps (I was seeing which one I liked). I want to take notes using a text editor as I want the notes to be generic ASCII text that I can import into anything. One day, without notice, without any rhyme or reason, permissions / ownerships of my folder changed. It’s now owned by root, rwxr-xr-x. I seem to be able to edit existing files there, but no app seems to be able to create new files there.

    Of course my SD card doesn’t have a Linux filesystem on it (ext4,xfs, etc.) – it has some variant of FAT, right? So the Unix permissions must be being stored somewhere. For example, I am speculating that there must be some kind of file, for example it could be called “.permissions” where these Linux ownerships, rwx permissions, etc. are stored. I should be able to take my SD card, drop it in my PC, edit that file, and fix the permissions – or something like that. But how?

    Or if I can fix the permissions using my phone, how? I don’t have root access to my phone. Frankly I need my phone, and can’t afford to brick it.

Leave a Reply

Your email address will not be published. Required fields are marked *