如何创建一个组,将用户添加到组中,并赋予该组对 linux 目录的完全访问权限

Dmi*_*sev 4 linux permissions

我的本地用户localUser有 directory /home/localUser。还有一个用户serviceUser运行一些服务,他需要完全访问我主目录中的一些文件夹。

我想创建组serviceGroup并在serviceUser那里添加。然后我想授予对home/localUser/workingFolder文件夹的完全访问权限。

怎么做?

lin*_*013 6

  • 假设一个用户将是 /home 为其创建的用户:

    -- 该用户默认拥有所有权限,至于其他人创建用户,然后将其添加到原始用户的组

    -- 然后确保GROUP有777权限

    sudo groupadd serviceGroup  ## Creates the needed group

    sudo useradd serviceUser  ## Adds the service tech user account

    sudo usermod -a -G serviceGroup serviceUser  ## Adds service Account to the service group 

    sudo chmod -R 777 $serviceGroup  ## grants  full access to the serviceGroup members 

    sudo chown -R localuser:serviceGroup /home/localuser  ## owner stays  localuser but  anyone in the serviceGroup "group" has access to its full  contents
Run Code Online (Sandbox Code Playgroud)