I am trying to change the ownership of a directory to a certain group.
I execute getent group and I see that the group I'm interested is in there - sudo:x:27.
Now I am executing chown in the following way:
sudo chown -R sudo /PATH/TO/DIR
And I get: id 'sudo': no such user
I also tried sudo chown -R 27 /PATH/TO/DIR - this commands actually being executed but then when I try for example to use mkdir in the directory I should own right now I get permission denied (and I did check with ls -l that the permissions changed).
What am I doing wrong?

2 Answers 2


chown takes the user and group as user:group. If you only want to change the group:

sudo chown -R :sudo /PATH/TO/DIR
  • (OT: sorry for the edit back and forth, I had a little trouble with the history of my browser) Sep 9, 2020 at 12:48
  • And this way this group will keep all of it's past ownerships right? nothing changes except from the added ownership?
    – Eliran Turgeman
    Sep 9, 2020 at 12:58
  • no, this will replace the current group of all subdirectories and files under that directory with the group group. Your question states that you want to CHANGE the group, not ADD another one. Sep 9, 2020 at 12:59
  • Oh so I am probably using the wrong command? I simply want a specific directory to be owned by the sudo group (so if im inside that group I can create/delete/copy files inside that folder)- is there another command that does this?
    – Eliran Turgeman
    Sep 9, 2020 at 13:04
  • 1
    This command does this. It will change the owning group. It will not change permissions. It will not change the owning user. Sep 9, 2020 at 13:06

Use the chgrp command. ie.

sudo chgrp -R /PATH/TO/DIR

Using chown will work with names or numbers... ie. specifying 27 would have worked if you had also specified the username/UID correctly. For example:

sudo chown -R 0:27 /PATH/TO/DIR  

would have set the ownership to root:sudo.

If you just want to change the group, chgrp may be easier for you.

If you only want to change a single directory, ie the one specified, omit the -R option.

If you want to change permissions, use the chmod command.

You must log in to answer this question.

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