1

I copied a file to my phone with this command:

adb push large.zip /data/local/

It took a few minutes and copied successfully, but then I realised that I couldn't find it on my phone. I copied it again to somewhere else (adb push large.zip /sdcard/media/), but then wanted to delete the first one, which is presumably using up about 10GB of storage for nothing. However, I can't find it:

adb shell
$ ls /data/local
 ls: /data/local: Permission denied
$ rm -f /data/local/large.zip
 rm: /data/local/large.zip: No such file or directory

a) How is it that I (with no root access) have permission to push a file to this directory with adb, but not view it?

b) Is there a way to delete it without root? Might it have been already deleted by some other mechanism?

Pixel 8, Android 14

1 Answer 1

3

Are you completely sure that the command below is what you actually ran? And that you didn't get any error messages?

adb push large.zip /data/local/

When I try doing something similar, I get:

adb push adb.exe /data/local/
adb: error: failed to copy 'adb.exe' to '/data/local/adb.exe': remote couldn't create file: Permission denied
adb.exe: 1 file pushed, 0 skipped. 120.7 MB/s (5857056 bytes in 0.046s)

That looks as if it succeeded, if you only look at the last line of the output, but it actually failed. This isn't very well handled, because the data is actually transmitted, which can take noticeable amounts of time for a large file. I've reported this in Google's issue tracker.

Addendum: I tried a further experiment:

Start an adb shell session and cd /data/local/tmp. That's a sub-directory of /data/local, where the shell account can create files, and generally do what it likes. Get the free space there:

df -k . 
Filesystem       1K-blocks     Used Available Use% Mounted on
/dev/block/dm-52 111478764 15015348  96332344  14% /storage/emulated/0/Android/obb

Start an additional command line window, and push a large file:

adb push largefile.zip /data/local
adb: error: failed to copy 'largefile.zip' to '/data/local/largefile.zip': remote couldn't create file: Permission denied
largefile.zip: 1 file pushed, 0 skipped. 30.4 MB/s (286500912 bytes in 8.992s)

Them check the free space again, and it has decreased, but not by anything like the size of the pushed file:

df -k .
Filesystem       1K-blocks     Used Available Use% Mounted on
/dev/block/dm-52 111478764 15015444  96332248  14% /storage/emulated/0/Android/obb

That doesn't prove there isn't a temporary directory used, but it does show that if there is, it gets cleaned up when adb push hits a permissions problem.

2
  • Thanks! I tried it again and reproduced that, so that must have been what happened. What misled me is that it copies for several minutes, and only throws the permission error at the end. I guess maybe it copies it to some temp directory first, and then only reassigns at the end? Commented Jul 8 at 7:03
  • 1
    @JoshFriedlander: Not sure about the temporary directory, I think there's a bug, or at any rate a misfeature. Revised the answer. Commented Jul 8 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .