[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Impossible to change ownership of a file to user when user is UID 0



On Mon, May 01, 2023 at 04:37:34PM +0200, Pierre Willaime wrote:
> On this system (not installed by me), my user has an UID and GID of 0 in
> /etc/passwd. Several users share root privileges like this on the server.

> 
> 	root@server:~# chown user /home/user/.ssh/authorized_keys 
> 	root@server:~# ls -la /home/user/.ssh/authorized_keys 
> 	-rw------- 1 root user 395  1 mai   15:38 .ssh/authorized_keys

Is "user" one of the accounts with UID 0?  If so, this is absolutely
expected behavior.  You're asking chown to change the owner to UID 0,
and it does so (which is a no-op).  Then you're asking ls to show you
a textual representation of the owner.  Obediently, ls uses the first
account that matches this UID, which happens to be named "root".


Reply to: