chown
is an abbreviation of "change owner". This command is used to change the owner and group owner of a file or directory
In Linux file permissions are set in three categories:
Since the owner, group and others may have different permissions, it is sometimes necessary to change the owner and group to control file access. This is done with the chown
command, which can set user and group ownership at the same time:
chown pixie file1 # make pixie owner of file1
chown pixie: file1 # make pixie owner and pixie group of file1
chown :sprites file1 # make sprites group of file1
chown pixie:sprites file1 # make pixie owner and sprites group of file1
chown
also has a -R
recursive flag, but to make future created files in a directory inherit the same group ownership rather than the creating user's group, the setgid bit should be added to the directory with chmod
.