Linux Group Permissions not being enforced correctly.

19,379

Solution 1

When adding a user to a new group, that won't be applied in any currently-running processes, only new ones. You need to log out and then log back in.

Solution 2

Both logging out and rebooting server methods didn't work for me.

This method however is working for me: (reference to this answer)

chmod g+rwxs <parent folder>
Share:
19,379

Related videos on Youtube

Gordon
Author by

Gordon

Updated on September 17, 2022

Comments

  • Gordon
    Gordon over 1 year

    I am running Ubuntu 10.04 server and am having some very counter-intuitive experiences with users/groups. For example:

    sudo touch test_file                    # create empty file
    
    sudo groupadd test                      # create 'test' group
    
    sudo chown root:test test_file          # change group of file to 'test'
    
    sudo chmod g+rwx test_file              # give write permissions to group
    
    sudo usermod -a -G test {my-user}       # add my user to 'test' group
    
    touch test_file                         # touch the file as my current user
    

    The last line produces a permissions error.

    I have ensured that my user is part of the 'test' group (groups {my-user} confirms this). The group of test_file is also definitely set to 'test' and the group permissions are set.

    Why can't my user write to the file test file?

  • Daenyth
    Daenyth almost 14 years
    This also has the effect of replacing your current group. It's not always a good idea.
  • matthias krull
    matthias krull almost 14 years
    or hack su - username into your running console. you dont have to logout to login this way :)
  • DrColossos
    DrColossos over 10 years
    There is no requirement that you must reboot the computer.
  • tommy.carstensen
    tommy.carstensen over 7 years
    What does the +s part do? Thanks.
  • Julius
    Julius about 7 years
    It sets the setuid bit. This allows a file to be run as the owner of the file. Suppose you have a file you want to run as root, no matter who the person is running the file, you would set the setuid bit for that file.
  • asac
    asac almost 6 years
    The key was x: looks like execution rights are needed for touch to work.
  • Edward
    Edward almost 6 years
    I would downvote this if i could. Overwriting groups could be very frustrating in the future... esp. with -R option!
  • Kamil Maciorowski
    Kamil Maciorowski over 3 years
    In the example touch test_file is a new process. It's not about currently-running vs new processes.