Check the file permissions with the ls
command.
$ ls -l
Something like drwxr-xr-x
represents the permission settings.
Alphabet | meaning |
---|---|
d | directory |
r | Read |
w | Writing |
x | Run |
- | Disallowed |
The leading d
indicates that it is a directory.
The rest represents three patterns of permissions: owner, group user, and other users.
drwxr-xr-x
will be in the following state.
Owner (u) | Group user (g) | Other users (o) | |
---|---|---|---|
d | rwx | r-x | r-x |
Directory | Permission to read, write, and execute | Read, execute permission, write disallow | Read, execute permission, write disallow |
To express rwx
as an octal number, it is as follows.
0 means no permission, 1 means permission.
rwx | 8 base |
---|---|
000 | 0 |
001 | 1 |
010 | 2 |
011 | 3 |
100 | 4 |
101 | 5 |
110 | 6 |
111 | 7 |
If you want to allow the operation only to the owner
rwx ------
becomes 111000000
and becomes 700
.
Give the owner write permission to the specified file
$ chmod u+w test.txt
Remove the execute permission of the owner of the specified file
$ chmod u-x test.txt
Or specify them all in octal numbers
$ chmod 700 test.txt
Recommended Posts