1

what is UID in linux? Wiki and other online sources say it is user ID. But what exactly is user id? The name "user id" gives me a sense that it is the user who is using the OS. Like If I have only one user, my user id should be 1. For root, I understand that it is 0.

But I see that the user id is given to every process(application ?). So, does every process has a different uid? Why is it needed when we have pid already to distinguish them.

Ex :
root:/ # ps 8533
USER     PID   PPID  VSIZE  RSS     WCHAN    PC        NAME
u0_a78    8533  363   1526628 52668 ffffffff b6f80d04 S com.google.android.keep

root:/ # cat /proc/8533/status
Name:   le.android.keep
State:  S (sleeping)
Tgid:   8533
Pid:    8533
PPid:   363
TracerPid:  0
Uid:    10078   10078   10078   10078
....

So here for the process google keep, the UID is 10078. So, are there more than 10000 users? If yes, then Who exactly is a user?

Sandeep
  • 18,356
  • 16
  • 68
  • 108

2 Answers2

1

UID is the Linux user ID.

User IDs don't have to start counting at 0 or 1. There's nothing that says that user IDs go up from 0, 1, 2, ... etc. so there is nothing strange with the fact that the UID is 10078.

On Android, every app gets its own Linux user. This is done for security management reasons; the permissions for each user = each app can be managed at the OS level in this way. Every time you install a new app, a new Linux user is created for that app.

This is explained in more detail in: Android System Permissions

The Linux user is an operating system level user, and does not have any direct relation to the person who is using the Android device.

Jesper
  • 202,709
  • 46
  • 318
  • 350
  • Great! "On Android, every app gets its own Linux user." - This answers my query like gem. So Can i assume that there are more than 10000 app installations done? Just to to clear my understanding, In ubuntu, does uid refer to the actual user using the OS? – Sandeep May 29 '15 at 06:47
  • No. Maybe it starts counting at 10000. Maybe the number 10078 means that you have 79 apps installed. In Ubuntu, there is indeed a Linux user for each actual user, and there are also a number of Linux users for other purposes. – Jesper May 29 '15 at 06:51
  • Thanks jesper. This blog here http://www.linfo.org/uid.html says, the uid's can be seen in /etc/passwd. While I cannot find this path in android, in ubuntu, it consists of data like "pulse:x:110:119:PulseAudio daemon,,,:/var/run/pulse:/bin/false" where 110 is the UID. But I was expecting my name(user) and not an application "pulse" here. Sorry for bothering you more. Could you please comment on this? – Sandeep May 29 '15 at 07:07
  • There's a separate user for PulseAudio. As I said, Linux users are not only for actual human users. There are also Linux users for specific processes, for example PulseAudio, etc. See [`man /etc/passwd`](http://linux.die.net/man/5/passwd) – Jesper May 29 '15 at 07:12
0

I payed attention that in Android (at least 5 and 6) any uid that is greater than 10000 corresponds to non-system user, i.e. non-system app.

mafonya
  • 2,152
  • 22
  • 21