Chown Command
Chown Command
The chown command allows you to change the owner and group owner of a file. Listing
our example.txt file with ls -l we can see dave dave in the file description. The
first of these indicates the name of the file owner, which in this case is the user
dave. The second entry shows that the name of the group owner is also dave. Each
user has a default group created when the user is created. That user is the only
member of that group. This shows that the file is not shared with any other groups
of users.
You can use chown to change the owner or group, or both of a file. You must provide
the name of the owner and the group, separated by a : character. You will need to
use sudo. To retain dave as the owner of the file but to set mary as the group
owner, use this command:
To change both the owner and the group owner to mary, you would use the following
command;
To change the file so that dave is once more the file owner and the group owner,
use this command: