Numeric uid and gid in ls -l command

I�m listing the contents of a directory using the command

ls -l

I get numeric uid and gid for some lines.
example:

drwxr-xr-x root     root              1970-01-01 01:00 sys
-rw-r--r-- 501      20              0 2010-08-04 14:54 shutdown.bravo.rc
drwxr-x--- 501      20                2010-08-04 14:54 sbin
dr-xr-xr-x root     root              1970-01-01 01:00 proc
-rwxr-x--- 501      20          15104 2010-08-04 14:54 init.rc

The command stat /sbin gives me

  File: "/sbin"
  Size: 0               Blocks: 0          IO Block: 4096   directory
Device: 1h/1d   Inode: 30          Links: 2    
Access: (0750/drwxr-x---)  Uid: (  501/ UNKNOWN)   Gid: (   20/ UNKNOWN)
Access: 1970-01-01 01:00:00.000000000
Modify: 1970-01-01 01:00:00.000000000
Change: 1970-01-01 01:00:00.000000000

The user id and group id are unknown.
What is corrupted here and how can I repair it?

  1. the files were created when uid 20 was in /etc/passwd and /etc/group

  2. or you are in a global zone on solaris looking at a child zone's files, and /etc/passwd & /etc/group are not in sync.

Looks like you are using gnu tools stat. But that runs a lot of places. What is your EXACT OS?

It's also possible to create files belonging to UID's and GID's that don't exist in some systems, someone might have extracted a tarball as root with -p and it preserved users down to the UID.

1 Like

Corona is right. The problem remains regardless of how it got there- what do you want to do about it?

find / -user 20  -exec chown [what user name]:[what group name]  {} \;

run that as root to fix it. user name and group have to be valid, existing values on your systems.

1 Like

The OS is Android.
I investigated this further and realized that android has a single user setup. The usual /etc/passwd does not exist. Instead there are some hard-coded uid and gid in system/core/include/private/android_filesystem_config.h. But uid 501 or gid 20 are not defined.

Mounting the filesystem alone revealed that some files have root:root ownership. Some are not existent. So I infer it must be changed during init phase.

For now I know how to change it using chown. I still wonder how that uid 501 and gid 20 is coming into play? Some of these files must be extracted during boot since they do not exist prior boot and have a time stamp prior boot time.

Probably hardcoded, again. Without an /etc/passwd, they're not using any normal login system, just using setuid() and setgid() manually. Groups and users will have their usual meanings but no labels, and perhaps not even a way to check which users belong to what groups anymore. (scratch that -- /proc/pid/status may be useful there.)

The group ID may be arbitrary. The user ID 501 may be the first or second non-admin user; the first created on my system was 1000, but I've seen it start at 500 elsewhere.

Another possibility has occurred to me: You may be operating in a chroot, denied access to the /etc/passwd file.