Ubuntu: Does chown always require sudo?



Question:

Why does an owner of a file in Ubuntu need to run sudo in order to execute chown.

Running it without sudo results in an "Operation not permitted" error messge.


Solution:1

File permissions are stored in the parent directory. You have to have w (write) access to the parent directory in order to change permissions, rename or delete files.

ls -ld .    

will show the directory permissions.


Solution:2

You only have to run sudo if you change the owner or the group to a group you don't belong to. You don't need sudo to change the group to a group you already belong to. Note that this is specified in the POSIX standard.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »