-2

I installed a fresh ubuntu with apache2.

I created a new folder "/var/www/foobar" with the following user:group -> black www-data.

I need new files created inside this folder to inherit the user and group of that folder.

So I executed chmod g+s /var/www/foobar

drwxr-xr-t 2 black www-data 4,0K Okt 9 10:12 foobar 

But if I create a new file inside this folder, then the user and group is set to black black instead of black www-data.

I also tried to add the user to the group www-data with sudo usermod -a -G www-data black but it made no difference.

What am I missing?

4
  • Reason for the downvote? Commented Oct 11, 2021 at 12:42
  • In your listing above, you are missing an s.. it should be drwxr-sr-t so the chmod didn't work. Commented Oct 12, 2021 at 10:51
  • There was no error message, it ran through. It just started to work after executing it with sudo. Commented Oct 12, 2021 at 11:45
  • Strange there was no error, but the missing bit change shown by ls is a clue. Commented Oct 13, 2021 at 11:33

1 Answer 1

0

You have to call chmod g+s <target_path> with sudo, otherwise it wont work.

Wrong:

chmod g+s /var/www/foobar

Correct:

sudo chmod g+s /var/www/foobar

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.