chmod Modify File Permissions 777 and 754 for Common Linux Commands

  • 2021-06-28 14:37:42
  • OfStack

The following command is commonly used:

chmod 777  文件或目录

Example: When chmod 777/etc/squid runs the command, the permissions for the squid folder (directory) are modified to 777 (read, write, executable).

If it is an Ubuntu system, you may need to add sudo to perform:

sudo chmod 777 /etc/squid

At the beginning of a story, there will always be a suspense.

There is a classic passage in the series of cold jokes that only programmers can understand:

Please describe FL in the simplest language.

754.

So what does 754 mean?What does 754 mean?What does 754 mean?

The chmod command is described in detail below.

In the Linux system, the roles and privileges of each user are divided very carefully and strictly. Each file (directory) has access permissions. This mechanism can be used to determine how a user reads, writes, executes a file (directory) in some way.

There are three different types of users who operate on files or directories: file owners, group users, and other users.The highest bit represents the file owner's permission value, the middle bit represents the group user's permission value, and the lowest bit represents the other user's permission value. Therefore, in chmod 777, the three numbers 7 correspond to each of the above three users, each with a permission value of 7.

There are three types of permissions for a file or directory: read-only, write-only, and executable.

权限 权限数值 2进制 具体作用
r 4 00000100 read,读取。当前用户可以读取文件内容,当前用户可以浏览目录。
w 2 00000010 write,写入。当前用户可以新增或修改文件内容,当前用户可以删除、移动目录或目录内文件。
x 1 00000001 execute,执行。当前用户可以执行文件,当前用户可以进入目录。

According to the table above, the permission combination is the sum of the corresponding permission values, as follows:

7 = 4 + 2 + 1 read and write permissions
5 = 4 + 1 read and run permissions

4 = 4 read-only permissions

So you know   chmod  754  filename  The meaning of the command.

This command means to give the file owner read and write access to the filename file, group users read and run access, and other users read access.

More official, detailed explanations can be found using the following commands:

chmod  --help   perhaps man  chmod


Related articles: