How to modify the permissions of a file or directory in linux (chmod)

Since linux is a multi-user operating system, linux implements strict permission division management for all files in the file system. Prevent unauthorized users from accessing a file.

Baidu experience: jingyan.baidu.com

Tools/Materials

 
  • linux
  • chmod

Baidu experience: jingyan.baidu.com

method/step

 
  1. 1

    The permissions of linux files or directories are divided into three permissions: read, write, and executable. The user categories for file access are divided into three categories: file creator, users in the same group as the file creator, and other users.

  2. 2

    The command to modify file permissions or directories is "chmod 755 test.sh". 755 means "creator has read-write-execute permissions, same group of users and other users have read and execute permissions".

  3. 3

    How is "755" formed: "0" indicates no permission, "1" indicates executable permission, "2" indicates write permission, and "4" indicates read permission. "7=1+2+4, 5=1+4".

  4. 4

    Use the "chmod 777 test.sh" command to use a user who can use the linux system with the same "read, write and execute permissions".

  5. 5

    There is another easy-to-understand way of giving permissions to files or directories in linux. For example: "chmod ax" means that all users will not have execute permission on this file or directory.

  6. 6

    "a" means all users, "u" means the creator, "g" means the creator is in the same group, "o" means other users; "+" means adding permissions, "-" means canceling permissions; "r" means reading Permission, "w" for write permission, "x" for write permission.

Guess you like

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