How to change linux file directory owner and user group

View users and groups

 
  1. 1

       First of all, before the experience operation, let's take a look at the users and groups under the current system. Whoami View currently logged in users

    How to change linux file directory owner and user group
  2. 2

    The Passwd file stores all users of the current system, while the group file /etc/group records.

    How to change linux file directory owner and user group
  3. 3

    A user can belong to multiple groups, view the group to which the user belongs, gourps + username

    How to change linux file directory owner and user group
    END

Change linux file directory\file owner permissions

 
  1. 1

    Change file owner (chown)

    [root@linux ~]# chown account name file or directory, as shown in the figure, change the owner of the file fail2ban to nginx

    How to change linux file directory owner and user group
  2. 2

    Change the user group of a file with the command chgrp

    [root@linux ~]# chgrp group name file or directory

    How to change linux file directory owner and user group
  3. 3

    You can also use the chown command

    Modify user and group at the same time, chown owner, group file\directory name

    How to change linux file directory owner and user group
  4. 4

    Override directory permissions

    After the directory permissions are modified, the default is to modify the permissions of the current level. If the subdirectories are also recursive, you need to add the R parameter

    How to change linux file directory owner and user group
  5. 5

    Chown -R : recursively, together with all files and directories in subdirectories

    How to change linux file directory owner and user group

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324884969&siteId=291194637