Home  >  Q&A  >  body text

Command line - How to authorize a folder to a certain user in Linux?

Under Linux, can a certain folder be authorized to a certain user or a certain group separately? Other users or groups have no permissions on the folder, and the ownership of the folder remains unchanged?
For example,
has the folder test1

The permission is drwxr-xr-x and the owner is A

A wants B to have the same permissions on the folder, and other users do not have the same permissions. The owner of the folder is still A

How to do it from the command line? I'm a noob, thanks for the advice.

漂亮男人漂亮男人2580 days ago1513

reply all(4)I'll reply

  • 世界只因有你

    世界只因有你2017-06-24 09:44:43

    1. Set the group permissions to be the same as the owner

    2. Add B to A’s group

    reply
    0
  • 漂亮男人

    漂亮男人2017-06-24 09:44:43

    If you want two users to have the same permissions, you first need to modify the folder permissions chmod 775 test1, and then change the group of B to the group of A or add B to the group of A. The usage is as follows:
    usermod -g group loginname
    Forcibly set the group a user belongs to
    usermod -G groups loginname
    Change a user to group(s)
    usermod -a -G groups loginname
    Add the user to a certain group(s)

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-06-24 09:44:43

    Just use acl.
    It seems to be written like this
    setfacl -m user:B:rwx test1

    reply
    0
  • ringa_lee

    ringa_lee2017-06-24 09:44:43

    chown [username] [folder]

    reply
    0
  • Cancelreply