Changing File Ownership
chown- change file owner and group
chown command allows you to change the ownership on any given file which will directly affect what users are able to
execute the target file.
chown [OPTION] [OWNER][:[GROUP]] [file-name]
Create a new file called
Check the current owner of the newly created file:
The current user
student in the
student group is the owner of the file
Change File Owner
Change the ownership of the file
chown-example to the root user.
sudo chown root chown-example
The new owner of the file
chown-example has been changed to the root user. However the
chown-example file still falls within the
Change File Group
To change the group of a file chown requires an additional argument:
sudo chown :root chown-example
You are able to add a
: to the
chown argument to change the group of a file.
chown command also allows you to change the user and group ownership with one command.
sudo chown student:student chown-example
The first argument of the chown command (prior to the
:) designates the file owner. The second argument designates the desired group.
- allows you to change user and group ownership of a file
chown [OPTIONS] file-name
chown new-user file-name: changes user ownership
chown :new-group file-name: changes group ownership
chown new-user:new-group file-name: changes both user and group ownership with one command