How can I use the chown command to change the ownership of all a folder's subfolders and files?

  • 3
    chown -R should work for you.
    – Wayne_Yux
    Commented Nov 3, 2015 at 12:59
  • 9
    chown -R your_username:your_group folder
    – Alex Lowe
    Commented Nov 3, 2015 at 13:15
  • Will any of these answers work if the files inside a folder are owned by someone else and only have user read/write permission?
    – taranaki
    Commented Oct 19, 2021 at 14:16
  • @taranaki Not really, as you are not the owner. If you precede the command with sudo, then that is a different story. (Btw, I know the question was from 2021, but still it might be useful for others!)
    – SRG
    Commented May 2 at 9:47

6 Answers 6


From chown --help:

Usage: chown [OPTION]... [OWNER][:[GROUP]] FILE...
  or:  chown [OPTION]... --reference=RFILE FILE...
Change the owner and/or group of each FILE to OWNER and/or GROUP.


  -R, --recursive        operate on files and directories recursively


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 the USERNAME: 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:


My username is timo and I did this to take ownership to all my files and folders on home directory (transferred from another account):

~$ sudo chown -R timo /home/timo/*
  • Worked for me. Thanks.
    – DarthWader
    Commented Nov 19, 2020 at 20:13
chown -R <username>:<groupname> <folder>

This is how I normally do it, and I usually do this one folder at a time. Doesn't take but a few moments to work through each folder.


I prefer: chown -hR :

This will also change ownership of symlinks instead of just the destination files that the symlinks point to.

  • "chown -hR root /u" mean change the owner of /u and subfiles to "root". Commented Dec 10, 2021 at 16:39
man chown
chown options user:group files/folders

Not sure why other answers did not cover one dot. : And . are interchangeable, so you can use one dot for instance

chown -R user.group files/folders

Either get to the terminal display mode as described elsewhere or do a ssh login from another computer. Usually the account is intact and it will be accessible via ssh.

You may also have an account on the same machine without the login loop problem. If you do, then login to that account (assuming it will let you sudo).

Once in, open a terminal and find the directory under which you can see the username directories. i.e. /home/username1 /home/username2

Run ls -l

if any of the user directories is owned by root change it by running:

sudo chown -R username:username /home/username 

This example is based on an architecture where the user directories are under /home/

Run ls -l again to confirm the directory is owned by the user.

This was tested on Ubuntu 20.04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .