How can I use the chown
command to change the ownership of all a folder's subfolders and files?
Ubuntu – Use chown to set the ownership of all a folder’s subfolders and files
chmoddirectorypermissions
Related Question
- Ubuntu – Change group access to directory and all sub directories and files
- Ubuntu – Delete files older than 5 days as well as in all subfolders
- Ubuntu – Is the user 999 safe
- Ubuntu – Defaulting new child files and folders to the parent folder ownership
- Ubuntu – chown subfolders with current folder’s owner and group
Best Answer
From
chown --help
:So you need to run (probably with
sudo
):Or, if the group shall be the specified user's primary group (usually same name), you can also omit the
GROUPNAME
and just give theUSERNAME:
with a colon (no space before it!). It will be set implicitly:To only change the user and leave the group as it is, just specify
USERNAME
and no group name and no colon:To only change the group and leave the owner user as it is, just specify
:GROUPNAME
with a leading colon: