5

I have a group called homeperms on an Ubuntu system, with a few users:

$ cat /etc/group | grep "homeperms"
homeperms:x:1004:jorik,tim.wijma,vanveenjorik,jorik_c

And I've done $ sudo chgrp -R homeperms /home. But when I try to

md /home/flask.

I get a permission denied error (Happens with any other folder name too).

I don't want to 777 the folders since I'm going to be dealing with web server stuff.

Permissions of home in /

drwxr-xr-x  12 vanveenjorik homeperms  4096 Jul  6 09:06 home

permissions inside /home:

drwxr-xr-x 6 vanveenjorik         homeperms 4096 Jul  3 20:08 19150
drwxr-xr-x 3 codeanywhere-ssh-key homeperms 4096 Jul  6 08:00 codeanywhere-ssh-key
drwxr-xr-x 2 vanveenjorik         homeperms 4096 Jul  6 09:13 downloads
drwxr-xr-x 5 vanveenjorik         homeperms 4096 Jul  4 08:43 jorik
drwxr-xr-x 4 jorik_c              homeperms 4096 Jul  6 08:09 jorik_c
drwxrwxr-x 4 vanveenjorik         homeperms 4096 Jul  3 20:15 mkdir_python
drwxr-xr-x 5 vanveenjorik         homeperms 4096 Jul  4 09:09 tim.wijma
drwxr-xr-x 3 vanveenjorik         homeperms 4096 Jul  3 18:20 ubuntu
drwxr-xr-x 5 vanveenjorik         homeperms 4096 Jul  4 09:27 vanveenjorik
drwxrwxr-x 3 vanveenjorik         homeperms 4096 Jul  3 22:28 venvs

I am trying to do this on the user 'jorik_c' and with sudo this (of course) works flawlessly

Before this gets marked as duplicate, the answer to this question, didn't help.

terdon
  • 234,489
  • 66
  • 447
  • 667
Jojo
  • 155
  • 1
  • 5

4 Answers4

5

By typing the command chgrp -R homeperms /home , You effectively changed the group ownership of /home and everything underneath to homeperms.

BUT, the group still does not have WRITE access on the directory. Per your output:

drwxr-xr-x  12 vanveenjorik homeperms  4096 Jul  6 09:06 home

Remember, file permissions display as: OWNER, GROUP, EVERYONE ELSE
You can fix it quickly by any of the following:

# retaining (rewriting) your existing permissions + toggling the WRITE-ACCESS bit for GROUP
chmod 776 /home

# similar, accomplished the same but simplified
chmod g+w /home
Eminent
  • 76
  • 3
2

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

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

Related

mint
  • 121
  • 3
  • @Peregrino69 The su command is used to become another user during a login session. As mentioned in the answer if the group was just created the user must re-login in order for the group's permissions to be applied. so if you re-login as the same user, you will get the permission to do the changes. – mint Sep 28 '21 at 15:09
  • Sorry, yes "only other answer" part removed. I had same issue after creating a new directory and assigned to a group. I resolved it by re-login with same user. – mint Sep 30 '21 at 06:53
  • Yap, now it's clear even to me :-) Except that is `su -l $USER` really the way to re-login, as you're now implying? – Peregrino69 Sep 30 '21 at 06:57
  • I used that to re-login and to make new shell – mint Oct 01 '21 at 07:34
  • I just tried `su -l pg` on my system (Debian 10 without significant tweaking) - `xmodmap` says `unable to open display` and login fails. So while it is valid way to login as a different user, it's not always a valid way to re-login as the same user. – Peregrino69 Oct 01 '21 at 07:50
  • Tested on ubuntu with $USER (environment variable which should always be your user) – mint Oct 01 '21 at 09:41
  • Tested with `su -l $USER`, which, yes, refers to my user pg when I'm logged in as pg. Exactly same result. – Peregrino69 Oct 01 '21 at 09:47
  • Both commands work on Ubuntu 20.04.1 su -l $USER & I tried with my user su -l mint. – mint Oct 01 '21 at 09:50
  • Yeah, I didn't say they don't. I'm only saying this isn't a process that can be trusted to universally work. Whether you take action on it is all up to you. I'm just a fellow community member pointing out errors / irregularities I spotted in order to help you to improve your answer :-) – Peregrino69 Oct 01 '21 at 09:51
  • ok, I can understand :) . so do you think this answer should not appear in this question. I answered to this because same issue happened to me and I fixed it using this command. – mint Oct 01 '21 at 10:39
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/130156/discussion-between-peregrino69-and-mint). – Peregrino69 Oct 01 '21 at 10:42
0

The ls -l shows that your group has only rx permissions on home dir. I think w permission is required for creating anything in the folder.

You can achieve this using the command: $ sudo chmod g+rwx /home

Jojo
  • 155
  • 1
  • 5
Vignesh SP
  • 308
  • 1
  • 11
0

As mentioned in other answers making sure your group permissions are correct is a vital step.

chmod g+w /home

However if you're still seeing this after those also match it could be that you added the user to the group during the same session. A log out/login will fix this error.

You can view the current session user's effective groups by executing the id command.

example

$ id
uid=1000(robert) gid=1000(robert) groups=1000(robert),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),998(docker),1001(appadmin)

See this post for detailed answer. https://askubuntu.com/questions/455000/group-permissions-allow-but-still-get-permission-denied

rcedwards
  • 1
  • 1