I've learned how to read permissions, so I'll take notes.
First, ** owning user ** and ** group ** are set for files and directories, and access rights are expressed by 9 characters such as rw-r--r--
.
First, create an appropriate file and check the permissions with the ls -l
command.
$ touch index.html
$ ls -l
total 0
-rw-r--r-- 1 user staff 0 12 25 10:55 index.html
** user ** User who owns the file or directory ** staff ** Group that owns files and directories
It shows what you can do with this index.html
file.
-rw-r--r--
The view is divided into 1: 3: 3: 3
-
rw-
r--
r--
** -
Indicates the file type **
** rw-
Access right of the owning user (user) **
** r--
Access rights for owned group (staff) **
** r--
Access rights of other users **
** File type **
Type | meaning |
---|---|
- | File |
d | directory |
l | Symbolic link |
** How to read access rights **
mode | Authority |
---|---|
r (read) | Readable |
w (write) | Writable |
x (execute) | Executable |
So the permissions on the index.html
file are
-rw-r--r-- 1 User staff 0 12 25 10:55 index.html
** User ** is ** readable and writable ** ** staff ** can only be read ** ** Other users ** can only read **
Becomes
rw-r--r--
This permission can be changed with the command chmod
rw-
is user's ** u **
r--
is ** g ** of group
r--
is another ** o **
All of this ** a ** of all
Can be handled with
For example, if you want to give all permissions to all users (user, group, other), write like this
$ chmod a=rwxrwxrwx index.html
$ ls -l
total 0
-rwxrwxrwx 1 user staff 0 12 25 10:55 index.html
If you want to give g the authority rw
o to rw
$ chmod g=rw,o=rw index.html
$ ls -l
total 0
-rwxrw-rw- 1 user staff 0 12 25 10:55 index.html
You can also add or delete permissions with +
or -
$ chmod g+x,o-w index.html
$ ls -l
total 0
-rwxrwxr-- 1 user staff 0 12 25 10:55 index.html
It can also be represented by numbers
mode | Numbers |
---|---|
r | 4 |
w | 2 |
x | 1 |
Access rights can be expressed by the sum of these numbers Example r + w + x = 7
mode | Numbers |
---|---|
rwx | 7 |
rw | 6 |
r | 4 |
For example, if you want to give the authority rwxrw-r--
$ chmod 764 index.html
$ ls -l
total 0
-rwxrw-r-- 1 user staff 0 12 25 10:55 index.html
When you want to make it rw-rw-r--
$ chmod 664 index.html
$ ls -l
total 0
-rw-rw-r-- 1 kuzeginjirou staff 0 12 25 10:55 index.html
I'm still studying, so I'd appreciate it if you could point out any corrections, etc. m (__) m
Recommended Posts