nugawiki

./categories/os

SUID SGID Sticky bit

업데이트 2026-07-21 조회수

SUID / SGID / Sticky bit

비트8진수ls 표시
SUID4s/S (소유자 x)
SGID2s/S (그룹 x)
Sticky1t/T (other x)

소문자 = 실행권한 있음, 대문자 = 실행권한 없음(비트만 설정).

# 설정
chmod u+s file          # SUID
chmod g+s file          # SGID
chmod o+t dir           # Sticky
chmod 4755 file         # SUID+755
chmod 2755 file         # SGID+755
chmod 1777 dir          # Sticky+777 (/tmp 등)

# 제거: + 대신 -
chmod u-s file

# 점검
find / -perm -4000 -o -perm -2000 -print 2>/dev/null   # SUID/SGID
find / -perm -2 -print                                  # world-writable
find / -nouser -o -nogroup -print
find /home -name .rhosts -print

예: /usr/bin/passwd는 root SUID → 일반 유저가 /etc/passwd 수정 가능. /tmp는 sticky(drwxrwxrwt)로 소유자만 삭제 가능.

./comments