Common Commands in Linux - Privilege Management Commands

Summary of file directory permissions
representative character permission Implications for the file Implications for the directory Score list
R readable Can view file content Can list the contents of a directory 4
W writable file content can be modified Can create and delete files in a directory 2
X executable executable file can enter the directory 1
In linux, we can use the ls -l command to view the owner, user group, and permissions of the owner, group and other groups of the file.
[root@admin ~] # ls -l file
-rwxrx-r-- 3 root root file

In the above example, - represents the type of file file, which is a file, in addition, d represents a directory file, and l represents a link file.

In the following parameters, each three is a group, all of which are rwx attributes. There are three groups in total, indicating the permissions of the owner, group, and other groups to which the file belongs. If there is no such permission Use - to indicate.

  • chgrp changes the ownership of a file or directory

Parameter options:

-R: Recursively change the group of files, that is, when changing the group of a directory file, if the -R parameter is added, the group of all files in the directory will be changed.

Syntax: chgrp [-R] group name file or directory name

[root @admin ~] # chgrp -R root dir1     
# Indicates that the group of the change directory and its subdirectories and subdirectories is root
  • chmod changes 9 attributes of a file or directory

Syntax 1: chmod [ugoa][+-=][rwx] file or directory name 

Syntax 2: chmod [nnn] file or directory name

[root @admin ~] # chmod a+x file #Indicates that the user, group, and other permissions of the file file are increased by x
  • chown Change the owner of a file or directory
Syntax: chown [-R] owner name file or directory name
[root @admin ~] # chown [-R] root dir #Change the owner of the directory dir and its files and subdirectories to root
  • umask View and set default permissions for files or directories

Syntax: umask [-S]


Guess you like

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