Dan

Authored Comments

This is important: "Depending on your role, you may need to use sudo to change ownership of a file."

If user "alan" is not a privileged user, he cannot give away ownership of his files to user "susan".

If user "susan" is not a privileged user, she cannot give those files back to user "alan", after ownership was given to her.

Only root can do that (I think). So running the command via "sudo" would be required to work through the examples.

This is interesting, from the man page for the "chown" system call
(man 2 chown):

"Only a privileged process (Linux: one with the CAP_CHOWN capability) may change the owner of a file. The owner of a file may change the group of the file to any group of which that owner is a member. A privileged process (Linux: with CAP_CHOWN) may change the group arbitrarily."

I'm not sure how a process gets the CAP_CHOWN capability. I suppose it is based on the invoking user. I'd be curious to learn how to do this for users alan and susan, as in the article.

Can this still be done by giving those users UID 0 and GID 0 in the /etc/passswd file?

I didn't know about "install". Thank you for showing us, Seth.

Re: "Unlike cp and cat, but exactly like mv, the install command can copy a file while preserving its timestamp...."

"cp" will also preserve atime and mtime with the "-p" or "-preserve" options.

AFAIK, any operation, including cp, mv and install, that modifies file metadata will update ctime, and there is no way to preserve ctime.