find명령어 -perm 옵션에서 +,-의 차이

OS/Linux 2016. 2. 11. 01:19 Posted by ­행복

find -perm 옵션의 +,- 차이점이 궁금해서 다음과 같은 실험을 해봤다.


1. test 디렉토리에 1~7이라는 파일을 만든 후, 각각의 chmod를 100~700으로 설정

root@kali:~/Documents# mkdir test

root@kali:~/Documents# cd test

root@kali:~/Documents/test# for i in {1..7}; do touch $i; done

root@kali:~/Documents/test# for i in {1..7}; do chmod "$i"00 $i; done



2. 다음과 같이 권한이 설정됨

root@kali:~/Documents/test# ls -al

total 8

drwxr-xr-x 2 root root 4096 Feb 11 01:08 .

drwxr-xr-x 4 root root 4096 Feb 11 01:08 ..

---x------ 1 root root    0 Feb 11 01:08 1

--w------- 1 root root    0 Feb 11 01:08 2

--wx------ 1 root root    0 Feb 11 01:08 3

-r-------- 1 root root    0 Feb 11 01:08 4

-r-x------ 1 root root    0 Feb 11 01:08 5

-rw------- 1 root root    0 Feb 11 01:08 6

-rwx------ 1 root root    0 Feb 11 01:08 7

root@kali:~/Documents/test#



3. 300 권한(write, executable)을 갖는 파일을 perm +,- 옵션을 주면서 검색


root@kali:~/Documents/test# find . -perm 300

./3


root@kali:~/Documents/test# find . -perm -300

.

./7

./3


root@kali:~/Documents/test# find . -perm +300

.

./5

./6

./7

./1

./2

./3



4. 결론

부호 없음 : 정확히 일치하는 결과 출력

+기호 : 부분집합 (w,x를 포함)시 출력

-기호 : 교집합 (w,x 중 하나라도 포함)시 출력



참고자료

http://hackerschool.org/HS_Boards/zboard.php?id=Free_Lectures&page=1&sn1=&divpage=1&sn=off&ss=on&sc=on&keyword=root&select_arrange=hit&desc=asc&no=1836

'OS > Linux' 카테고리의 다른 글

cifs 마운트시 유의점  (0) 2016.08.31
리눅스 파일 시스템 구조  (0) 2016.03.02
PCB  (0) 2016.03.02
ssh rsa key 확인 없이 로그인  (0) 2016.02.22
umask  (0) 2016.02.10