7

I'm trying to set up my Linux server and I managed to get stuck at this point:

  1. I created a group called 'gitusers' and added a user to it (let's call him 'foo')
  2. I created a folder called 'website'
  3. I set 'gitusers' as the group of 'website' and chmod'ed it to 775
  4. I'm logged in as 'foo' but mkdir just returns a 'permission denied' error

Q: Why does this happen and how do I solve this?

Notes:

I browsed to 'website' and did a ls -al:

ls -al
total 8
drwxrwxr-x. 2 root gitusers 4096 Oct 24 22:39 .
drwxr-xr-x. 3 root root     4096 Oct 24 22:39 ..

As you can see the current folder's group is 'gitusers'

But I still get the permission error:

mkdir test
mkdir: cannot create directory `test': Permission denied
4
  • What do commands like id, id -a, and groups show? Can you create plain files in the "website" directory? Do you have ACLs? Oct 24, 2013 at 23:30
  • 7
    If you just created the group, make sure to re-login with the user. Oct 24, 2013 at 23:39
  • Thank you Oliver, I didn't think of that. That was the issue! Oct 24, 2013 at 23:43
  • I cannot re-login, or I lose access to the machine. What are other options? Thank you!
    – atripes
    Dec 22, 2014 at 23:40

2 Answers 2

7

If the group was just created the user must re-login in order for the group's permissions to be applied.

Expanding on the only other answer:

su -l $USER 

su changes the effective user. -l indicates that we should make this new shell into a login shell $USER is a environment variable which should always be your user. Same results as whoami

P.S. You may wish to re-export your display if you wish to use GUI applications.

export DISPLAY=:0.0

Will work for most people.

Related superuser question

-1
exec su -l $USER 

should fix this.

2
  • 4
    can you expand on this a bit more? Explain more about what this command does?
    – studiohack
    Feb 14, 2015 at 2:42
  • 1
    @studiohack You are re-logging in (possibly even as yourself), thus within that prompt you already gain your ‘new group member powers’. (The ones that you truly and fully and globally get only after logout+login)
    – Frank N
    Mar 26, 2022 at 9:56

You must log in to answer this question.

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