chown with numeric arguments
I tried this on Opensuse 12 and Fedora 17, i use the following commans
touch file
chown 777 file
ls -l file
-rw-r--r-- 1 777 root 0 Oct 9 21:43 file
grep 777 /etc/passwd
echo $?
1
There is no user 777
grep pippo /etc/passwd
echo $?
1
chown pippo file
chown: invalid user: `pippo'
But if i use non-existing user, i get one error.
Why can i use numeric non-existing user with chown, but not with names?
Solution 1:
Why can i use numeric non-existing user with chown, but not with names?
Because a username must be resolved to a UID, so if the user does not exist no resolution can occur, whereas a UID is a terminating type (it describes itself without resolution).
Technically all chown requests by the operating system must be done against a UID. The username is for your benefit, not the operating system.