As this relevant Stack Overflow question revision demonstrates, calling $USER inside a terminal (like Termux) provides a username like u0_a272. However, every application developer I've spoken to about this who was able to discuss this informed me that that value differs for each application, and the AOSP documentation appears to corroborate this.

Consequently, should I consider the u0 section as the user identifier, and the _.* section as the identifier for the application, or is an entirely different method utilized to refer to a user?

  • 1
    While there's nothing wrong with the question, I have a trouble understanding the context of ”AOSP" in the title, because I thought "AOSP" as the project/source code as a whole, not the OS/app. Perhaps it's only me?
    – Andrew T.
    Commented Jun 18 at 5:54
  • @AndrewT. I use AOSP to refer to the OS in its unmodified form, since unlike most Linux-based OSes, "Android" has an official base form. If you know of official guidance which contradicts this, I shall rephrase it. Commented Jun 18 at 12:44

1 Answer 1


It is well known that Android uses the Linux user system as simple sandbox system to separate the apps form each other.

The Android user id like u0_a272 (UID 10272) can be interpreted this way:

  • u0 means it belongs to the first user-account on the device (this time to the Linux user account but human user).
  • a is may be the identifier that the user account belongs to an app (not 100% sure)
  • 272 is the Linux UID modulo UserHandle.PER_USER_RANGE.

The UID is computed as:

UID = UserHandle.PER_USER_RANGE × user + app + Process.FIRST_APPLICATION_UID

Constants in Process specify range of UIDs allowed for use by the applications. On Android M, the range is from 10000 to 19999.

The user accounts are created dynamically on app installation and then saved to a XML file where this and many more details if all installed apps are recorded. This way Android can lookup which app belongs to which uid and the other way round.

For more details on this topic see the related questions and their answers:

  • 1
    This is mostly correct, however the part after the underscore is not (directly) a Linux id nor is it hex. Both numbers are decimals, and the first part identifies the human Android user (u0 = the first account set up on the device; u1 would be used if you add an additional profile, and so on), and the a123 identifies the app number, which is assigned in the order the apps are installed. So u0_a12 would be the 12th app that the main user installed, and the answer to the original question is "yes".
    – josh3736
    Commented Jun 18 at 4:52
  • @josh3736 Thanks for the additional info. I just checked reality and regarding the part after the underscore we are more or less both correct. Checking my /data/data directory using ls -la and ls-lan I can see e.g. that u0_a29 has uid 10002 and u0_a266 has uid 10266. This pattern was valid for all apps I have checked.
    – Robert
    Commented Jun 18 at 7:24

You must log in to answer this question.

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