HOWTO: Use CHOWN
In the GNU/Linux operating system, the rights that any given user has to a file are largely decided by their relationship to the owner of the file. If you’re into punishment, I’ve explained fie permissions in my stunningly boring OGG file and my even more boring written entry on the chmod command.
In essence, a before giving a user access to the file, the OS will determine if the user requesting the file is the owner of the file, in the same group as the owner of the file, or neither. Access to the file will be given based on these criteria.
Sometimes, it may be necessary to change the owership of a given file. You can change the owner or group (or both) of a file to affect how its permissions are applied.
Consider user joe who is a member of the sales group. Further, consider this file:
-rw-rw—- 1 sandy sales 1302 Jun 13 13:25 report.ods
This file is named report.ods and is owned by the user sandy who is a member of the sales group. Sandy, as the owner, has read and write access to the file, as does everyone else in the sales group. Nobody else has any rights to it. So, at this moment, user joe can access and modify this file because he’s in the sales group.
However, if I were to issue the command:
chown sandy.marketing report.ods
That would make the file look like this:
-rw-rw—- 1 sandy marketing 1302 Jun 13 13:25 report.ods
User sandy would continue to have full access to the file because she still owns it, however user joe would lose all access to it now. Why? Because I’ve changed the group ownership to marketing - a group to which user joe does not belong. Prior to my change, user joe had access to the file based on the read/write privileges assigned to joe’s group - the sales group. Now that the sales group has no access to the file (sales is now in the ‘other’ permissions category), joe loses all access.
Like many Linux commands, chown can take a few arugments to allow the mass management of file permissions. Check out man chown for more info on that.
Related Stories
POSTED IN: How To
2 opinions for HOWTO: Use CHOWN
abay
Mar 25, 2007 at 9:44 pm
I’d like to know what the meaning of:
chown 0 /bla/bla
Example:
chown 0 /usr/local/apache/bin/httpd
Charles
Oct 16, 2007 at 5:00 pm
Best I ever seen! Great job explaining chown.
Have an opinion? Leave a comment: