sudo chown
Unlike chmod command, chown only becomes useful if run with elevated (root) privileges. In Linux, it is most commonly used with the help of sudo command.
Why sudo is needed for chown
Basic security model in Unix is around users and groups and their ownership of various files and directories. This means that without elevated privileges (becoming root or running commands via sudo) no regular user is meant to have enough privileges to act on behalf of another user.
Example of sudo chown
Here’s how we would run chown to change ownership of my own files (belonging to user greys) to root and back:
Without sudo our chown attempt will fail:
…but with sudo it does the trick:
That’s all I wanted to share today. Have fun!
See Also
Unlike chmod command, chown only becomes useful if run with elevated (root) privileges. In Linux, it is most commonly used with the help of sudo command.
Why sudo is needed for chown
Basic security model in Unix is around users and groups and their ownership of various files and directories. This means that without elevated privileges (becoming root or running commands via sudo) no regular user is meant to have enough privileges to act on behalf of another user.
Example of sudo chown
Here’s how we would run chown to change ownership of my own files (belonging to user greys) to root and back:
Without sudo our chown attempt will fail:
…but with sudo it does the trick:
That’s all I wanted to share today. Have fun!