Owner (u) Group (g) Public (o)
Read (4)
Write (2)
Execute (1)
000
---------

Description

Calculate chmod permissions. In Linux, use chmod to assign permissions to files or directories.
How to represent multiple states using a single field?
1. Each value needs to be in the format of 2^n (1, 2, 4, 8, 16, 32...).
2. To represent 2, the value is 2; to represent both 2 and 4, the value is 4+2 = 6.
Calculation process: (value & comparison value) = comparison value, for example, (6&2) == 2, (6&4) == 4.