1. Download our Official Android App: Forums for Android!

How to give RW permissions to file in android using pc commandline

Discussion in 'Android Apps & Games' started by kirankvb, Jan 12, 2018.

  1. kirankvb

    kirankvb Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    22
    Joined:
    Jul 28, 2014

    Jul 28, 2014
    22
    0
    15
    I am going to create zip file, so in that, I need to change the file permission to rw-r-r and I want the command line in order to type in terminal
    I know how to change using GUI but I want using command line
    I copied some files in the "system/" directory and want to give some permissions to it
    can anyone help me

     

    Advertisement

  2. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,452
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,452
    10,738
    1,988
    Male
    Software developer
    South West of England
    chmod 644 filename
     
    lunatic59 and Hadron like this.
  3. Hadron

    Hadron  
    VIP Member
    Rank:
     #7
    Points:
    2,218
    Posts:
    22,532
    Joined:
    Aug 9, 2010

    Aug 9, 2010
    22,532
    15,845
    2,218
    Spacecorp Test Pilot
    Dimension Jumping
    And it's a Linux command line, not a PC one - helpful to know if you need to look up what commands exist (PC command line will probably get you DOS or Windows).
     
  4. kirankvb

    kirankvb Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    22
    Joined:
    Jul 28, 2014

    Jul 28, 2014
    22
    0
    15
    so if I want to copy a file to /system which command I have to type in command prompt
    i want to create a script in that i want to copy some files from computer to android system and changing the read/write permissions
    If you know anything about that just help me
     
  5. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,452
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,452
    10,738
    1,988
    Male
    Software developer
    South West of England
    You'll need to have root permission to do this. /system isn't accessible to normal users, so your phone must be rooted.
    Assuming this is the case, then you'll use a command similar to this

    Code (Text):
    1.  
    2. adb push Settings.apk /system/apps/
    3.  
    https://www.droidviews.com/push-pull-files-android-using-adb-commands/
     
    kirankvb and lunatic59 like this.
  6. kirankvb

    kirankvb Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    22
    Joined:
    Jul 28, 2014

    Jul 28, 2014
    22
    0
    15
    I understood
    but how can I change the permission of and apps and folder to rw-r-r and rwx-rx-rx using command line
     
  7. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,452
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,452
    10,738
    1,988
    Male
    Software developer
    South West of England
    See post #2

    chmod 644 is rw-r-r
    chmod 755 is rwx-rx-rx
     
    kirankvb likes this.
  8. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,452
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,452
    10,738
    1,988
    Male
    Software developer
    South West of England
    to change all files in current directory, and subfolders, issue the command

    find . -exec chmod 644 {} \;
     
    kirankvb and bcrichster like this.
  9. svim

    svim Android Expert
    Rank:
     #45
    Points:
    608
    Posts:
    3,866
    Joined:
    Dec 19, 2013

    Dec 19, 2013
    3,866
    2,875
    608
    Illinois
    If you really want to get comfortable using CLI commands instead of relying on a GUI, it would be very beneficial to learn some fundamentals. Using the chmod command to change permissions might appear to be daunting in the beginning but once you take the time to absorb the basics behind it, things become much more logical. Try reading through this primer a few times:
    https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-permissions
    Keep in mind using chmod that you have just these items to focus on:
    1) three values - 4, 2, and 1
    2) three permissions - read (r), write (w), and execute (x)
    3) three classes - user, group, and other
    So that, "rw-r-r" you had in your initial posting is, in a formal setting, incorrect syntax. At minimum you always should have at least nine total, so it should be rw-r--r-- (with the - signifying that permission is not enabled. Plus it's always the same order -- read/write/execute and user/group/other -- those never change.) Getting back to your original query, it would be 644, or to break it down:
    owner group other
    r(4) w(2) x(-)
    r(4) w(-) x(-)
    r(4) w(-) x(-)

    Since your question has already been answered, the primary reason I'm even replying is in this instance you'll be much better off in the long-term if you're familiar with permissions. It's not to dissuade you from asking for help or to be dismissive but there are some seriously hostile souls out in the Internet. Asking for a string of code on a public forum can result in a some posting with what appears to be safe but in actuality could also include a command that can be very problematic. That won't happen here in AF of course ;-) but elsewhere there's no shortage of examples were someone asks for a help and a reply contains a command that deletes everything on the drive.
     
    kirankvb likes this.
  10. kirankvb

    kirankvb Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    22
    Joined:
    Jul 28, 2014

    Jul 28, 2014
    22
    0
    15
    Thank you so much
    i really want to know about that and you explained me a lot
     

Share This Page

Loading...