chown command not mapping uid with passwd file

Latest response

I'm having problem with chown command. I tried to use chown command to change ownership of my directory by using uid instead of username, however, uid not mapping with passwd file.

example below:

user info from passwd:
root@devinfra1:/root#id mozahar
uid=513001(mozahar) gid=1271(users) groups=1271(users)

my directory:
root@devinfra1:/root#ls -ld test_dir
drwxr-x--- 2 mozahar users 6 Oct 26 12:46 test_dir

when I ran chown command with uid, it change ownership to uid instead of username:
root@devinfra1:/root#ls -ld test_dir
drwxr-x--- 2 mozahar users 6 Oct 26 12:46 test_dir
root@devinfra1:/root#chown -v 513001:users test_dir
changed ownership of ‘test_dir’ from mozahar:users to 513001:users
root@devinfra1:/root#ls -ld test_dir
drwxr-x--- 2 513001 users 6 Oct 26 12:46 test_dir

it suppose to retained ownership to "mozahar" instead of changing to "513001".

but this problem seems like happen to some user only

root@devinfra1:/root#ls -ld test_dir
drwxr-x--- 2 513001 users 6 Oct 26 12:46 test_dir

root@devinfra1:/root#id lowpc
uid=465881(lowpc) gid=1271(users) groups=1271(users)

root@devinfra1:/root#chown -v 465881:users test_dir
changed ownership of ‘test_dir’ from 513001:users to 465881:users

root@devinfra1:/root#ls -ld test_dir
drwxr-x--- 2 lowpc users 6 Oct 26 12:46 test_dir

Responses

Hi Zahari,

Interesting problem.

Can you please provide results of the following checks:

# pwck

# grpck

# getent passwd mozahar

# getent passwd lowpc

Regards,

Dusan Baljevic (amateur radio VK2COT)