user:
user는 파일의 소유자입니다. 기본적으로 파일을 만든 사람이 소유자가 됩니다. 따라서 user를 소유자라고 하기도 합니다.
group:
group에는 여러 user가 포함될 수 있습니다. 그룹에 속한 모든 user는 파일에 대한 동일한 group 액세스 권한을 갖습니다. 많은 사람이 파일에 액세스해야 하는 프로젝트가 있다고 가정합니다. 각 user에게 일일이 권한을 할당하는 대신에 모든 user를 group에 추가하고, 파일에 group 권한을 할당할 수 있습니다.
other:
파일에 대한 액세스 권한이 있는 다른 user입니다. 파일을 만들지 않은 다른 모든 user를 의미합니다. 따라서 other 권한을 설정하면, 해당 권한을 global 권한 설정이라고 볼 수도 있습니다.
--r: read permission(읽기권한)
--w: write permission(쓰기권한)
--x: execute permission(실행권한)
Access class Operator Access Type
u (user) + (add access) r (read)
g (group) - (remove access) w (write)
o (other) = (set exact access) x (execute)
a (all: u, g, and o)
chmod g-r filename # removes read permission from group
chmod g+r filename # adds read permission to group
chmod g-w filename # removes write permission from group
chmod g+w filename # adds write permission to group
chmod g-x filename # removes execute permission from group
chmod g+x filename # adds execute permission to group
chmod o-r filename # removes read permission from other
chmod o+r filename # adds read permission to other
chmod o-w filename # removes write permission from other
chmod o+w filename # adds write permission to other
chmod o-x filename # removes execute permission from other
chmod o+x filename # adds execute permission to other
chmod u+x filename # adds execute permission to user
chmod a=rw helloworld.js # -rw-rw-rw-
chmod u= helloworld.js # ----rw-rw-
chmod a+rx helloworld.js # -r-xrwxrwx
chmod go-wx helloworld.js # -r-xr--r--
chmod a= helloworld.js # ----------
chmod u+rwx helloworld.js # -rwx------
Permission Number
Read (r) 4
Write (w) 2
Execute (x) 1
# Sum rwx Permission
7 4(r) + 2(w) + 1(x) rwx read, write and execute
6 4(r) + 2(w) + 0(-) rw- read and write
5 4(r) + 0(-) + 1(x) r-x read and execute
4 4(r) + 0(-) + 0(-) r-- read only
3 0(-) + 2(w) + 1(x) -wx write and execute
2 0(-) + 2(w) + 0(-) -w- write only
1 0(-) + 0(-) + 1(x) --x execute only
0 0(-) + 0(-) + 0(-) --- none