in reply to using chown to change file ownership
I don't know how to get the username from any number.
getpwuid and for the group name getgrgid. To get the UID and GID from a name use getpwnam and getgrnam.