2

I'm using Ubuntu 16.04 and want to create a shared directory, but after creating it, I'm not able to create files in it even if I'm member of the group.

Here is what I did and what I got:

enter image description here

It works when running sudo su instead of sudo, but normally I should have the required permissions.

What is the source of the issue?

Yaron
  • 13,173
00-Yalo
  • 155
  • 2
    You are sure you are member of the group? Do id to find out. You have to log out and in again to reload the group membership! – ridgy Dec 31 '17 at 12:41
  • Please note that /usr/local/share is meant for read-only architecture-independent data files (see Filesystem Hierarchy Standard for more details). This isn't supposed to be user data, but rather applications' data. You seem to misunderstand its purpose. – Ruslan Dec 31 '17 at 17:35

1 Answers1

5

Creating a file in that directory required that you'll be either root or in group music.

It seems like the reason you failed to create the file, is that your user isn't included in group music.

  • You can check that by running id command - which will show the groups you are member in (thanks for @ridgy comment)

  • As explained here you can add your user to a group using:

    sudo usermod -a -G groupName userName
    

Note: You might need to logout/login in order to update the group list of your user.

Yaron
  • 13,173
  • @PerlDuck - the OP execute the command > /usr/local/share/Music/test_file - the command will create a new file the right permissions exists. (note the > at the beginning) – Yaron Dec 31 '17 at 12:57
  • @PerlDuck - to test it yourself, try for example running > /etc/test_PerlDuck as regular user on your machine, and see the error you'll get – Yaron Dec 31 '17 at 12:59
  • @PerlDuck - NP :) - do you agree with my answer now? – Yaron Dec 31 '17 at 13:05
  • Yes. My suggestion for the OP would be: 1) make sure (by issuing id) you're member of music. If not, use usermod … and logout/in for the changes to take effect. That's about what you wrote. – PerlDuck Dec 31 '17 at 13:07
  • @PerlDuck - thanks for your comment, I've edited my answer to be clearer (as you suggested) – Yaron Dec 31 '17 at 13:11
  • 1
    Well, *I* would accept your answer now ;-) – PerlDuck Dec 31 '17 at 13:15
  • 1
    That Foot of the Rainbow hat looks … umm … funny. – PerlDuck Dec 31 '17 at 15:33
  • Executing newgrp will apply changes made to /etc/group without having to log out/in, it launches a new shell instance with the updated group memberships. (It's actually a new instance launched as a child of the old, so exit will drop you back to the previous, outdated-groups parent, and of course it won't affect any of the rest of the session, including other shells or the GUI.) – FeRD Dec 31 '17 at 18:37
  • (Actually, let me amend that: Executing newgrp <groupname> will launch a child shell instance which has the user as a member of the named group, assuming the relevant changes have been made to /etc/group and friends. For some reason a bare newgrp doesn't pick up changes, though I thought it used to.) – FeRD Dec 31 '17 at 18:48