DrawingProcess
λ“œν”„ DrawingProcess
DrawingProcess
전체 방문자
였늘
μ–΄μ œ
Β«   2025/06   Β»
일 μ›” ν™” 수 λͺ© 금 ν† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
  • λΆ„λ₯˜ 전체보기 (964)
    • Profile & Branding (22)
      • Career (15)
    • IT Trends (254)
      • Conference, Faire (Experien.. (31)
      • News (187)
      • Youtube (19)
      • TED (8)
      • Web Page (2)
      • IT: Etc... (6)
    • Contents (97)
      • Book (66)
      • Lecture (31)
    • Project Process (94)
      • Ideation (0)
      • Study Report (34)
      • Challenge & Award (22)
      • 1Day1Process (5)
      • Making (5)
      • KRC-FTC (Team TC(5031, 5048.. (10)
      • GCP (GlobalCitizenProject) (15)
    • Study: ComputerScience(CS) (72)
      • CS: Basic (9)
      • CS: Database(SQL) (5)
      • CS: Network (14)
      • CS: OperatingSystem (3)
      • CS: Linux (39)
      • CS: Etc... (2)
    • Study: Software(SW) (95)
      • SW: Language (29)
      • SW: Algorithms (1)
      • SW: DataStructure & DesignP.. (1)
      • SW: Opensource (15)
      • SW: Error Bug Fix (43)
      • SW: Etc... (6)
    • Study: Artificial Intellige.. (149)
      • AI: Research (1)
      • AI: 2D Vision(Det, Seg, Tra.. (35)
      • AI: 3D Vision (70)
      • AI: MultiModal (3)
      • AI: SLAM (0)
      • AI: Light Weight(LW) (3)
      • AI: Data Pipeline (7)
      • AI: Machine Learning(ML) (1)
    • Study: Robotics(Robot) (33)
      • Robot: ROS(Robot Operating .. (9)
      • Robot: Positioning (8)
      • Robot: Planning & Control (7)
    • Study: DeveloperTools(DevTo.. (83)
      • DevTool: Git (12)
      • DevTool: CMake (13)
      • DevTool: NoSQL(Elastic, Mon.. (25)
      • DevTool: Container (17)
      • DevTool: IDE (11)
      • DevTool: CloudComputing (4)
    • 인생을 μ‚΄λ©΄μ„œ (64)
      • λ‚˜μ˜ μ·¨λ―Έλ“€ (7)
      • λ‚˜μ˜ 생각듀 (42)
      • 여행을 λ– λ‚˜μž~ (10)
      • 뢄기별 회고 (5)

개발자 λͺ…μ–Έ

β€œ λ§€μ£Ό λͺ©μš”μΌλ§ˆλ‹€ 당신이 항상 ν•˜λ˜λŒ€λ‘œ μ‹ λ°œλˆμ„ 묢으면 μ‹ λ°œμ΄ ν­λ°œν•œλ‹€κ³  생각해보라.
컴퓨터λ₯Ό μ‚¬μš©ν•  λ•ŒλŠ” 이런 일이 항상 μΌμ–΄λ‚˜λŠ”λ°λ„ 아무도 λΆˆν‰ν•  생각을 μ•ˆ ν•œλ‹€. ”

- Jef Raskin

λ§₯의 아버지 - μ• ν”Œμ»΄ν“¨ν„°μ˜ λ§€ν‚¨ν† μ‹œ ν”„λ‘œμ νŠΈλ₯Ό 주도

인기 κΈ€

졜근 κΈ€

졜근 λŒ“κΈ€

ν‹°μŠ€ν† λ¦¬

hELLO Β· Designed By μ •μƒμš°.
DrawingProcess

λ“œν”„ DrawingProcess

[Linux] chmod 파일 κΆŒν•œ 및 특수 κΆŒν•œ μ„€μ •
Study: ComputerScience(CS)/CS: Linux

[Linux] chmod 파일 κΆŒν•œ 및 특수 κΆŒν•œ μ„€μ •

2023. 1. 26. 13:27
λ°˜μ‘ν˜•
πŸ’‘ λ³Έ λ¬Έμ„œλŠ” 'chmod νŒŒμΌ κΆŒν•œ λ° νŠΉμˆ˜ κΆŒν•œ μ„€μ •'에 λŒ€ν•΄ 정리해놓은 κΈ€μž…λ‹ˆλ‹€.
Linux OSμ—μ„œλŠ” 파일 및 폴더에 μ ‘κ·Ό κΆŒν•œμ΄ μ‘΄μž¬ν•©λ‹ˆλ‹€. 이둜 인해 νŠΉμ • νŒŒμΌμ— μ ‘κ·Όν•  λ•Œ 'permissionError', 'Permission denied'와 같은 μ—λŸ¬κ°€ λ°œμƒν•  수 μžˆλŠ”λ°, μ΄λ•Œ 파일의 μ ‘κ·Ό κΆŒν•œ 섀정에 λŒ€ν•΄ μ•Œκ³  μžˆλ‹€λ©΄ λ§Žμ€ 도움이 될 것 κ°™μ•„ μ •λ¦¬ν•˜μ˜€μœΌλ‹ˆ μ°Έκ³ ν•˜μ‹œκΈ° λ°”λžλ‹ˆλ‹€.

1. Linuxμ—μ„œ κΆŒν•œμ΄λž€?

1.1 폴더 μ ‘κ·Ό κΆŒν•œ ν™•μΈν•˜κΈ°

'ls -al', 'll' 의 λͺ…령어에 경둜λ₯Ό 뢙이면 ν•΄λ‹Ή κ²½λ‘œμ— μœ„μΉ˜ν•œ νŒŒμΌλ“€μ˜ μ ‘κ·Ό κΆŒν•œ(e.g. drwxr-xr-x)을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

$ ll /
total 2097252
drwxr-xr-x  21 root root       4096  8μ›” 31 13:50 ./
drwxr-xr-x  21 root root       4096  8μ›” 31 13:50 ../
lrwxrwxrwx   1 root root          7  7μ›” 26  2022 bin -> usr/bin/
drwxr-xr-x   4 root root       4096  1μ›” 17 06:40 boot/
drwxr-xr-x   3 root root       4096  8μ›” 31 13:50 build/
drwxrwxr-x   2 root root       4096  7μ›” 26  2022 cdrom/
drwxr-xr-x  19 root root       4600  1μ›” 25 12:39 dev/
drwxr-xr-x 146 root root      12288  1μ›” 26 09:04 etc/
drwxr-xr-x   9 root root       4096  1μ›” 25 16:44 home/
lrwxrwxrwx   1 root root          7  7μ›” 26  2022 lib -> usr/lib/
...
drwxrwxrwt  38 root root      12288  1μ›” 26 12:00 tmp/
drwxr-xr-x  14 root root       4096  2μ›”  4  2021 usr/
drwxr-xr-x  14 root root       4096  2μ›”  4  2021 var/

λͺ…λ Ήμ–΄λ₯Ό 톡해 ν™•μΈν•˜λ©΄ ν΄λ”λ§ˆλ‹€ λ‹€μ–‘ν•œ μ ‘κ·ΌκΆŒν•œμ„ κ°–λŠ” 것을 λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. μ•„λž˜μ—μ„œ μ΄λŸ¬ν•œ μ ‘κ·Ό κΆŒν•œμ΄ 무슨의미λ₯Ό κ°–λŠ”μ§€ 확인해보도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€.

1.2 폴더 μ ‘κ·Ό κΆŒν•œ λΆ„μ„ν•˜κΈ°

drwxrwxrwx κΆŒν•œμ€ d/rwx/rwx/rwx 와 같이 λ‚˜λˆ„μ–΄ 해석할 수 μžˆμŠ΅λ‹ˆλ‹€.

μ—¬κΈ°μ„œ d λŠ” directory의 μ•½μžλ‘œ ν•΄λ‹Ή 파일 μžμ²΄κ°€ ν΄λ”μž„μ„ λ‚˜νƒ€λƒ…λ‹ˆλ‹€.

이후 rwx λ“±μ˜ λ¬Έμžμ—΄μ΄ 3번 λ°˜λ³΅λ˜λŠ”λ°, μ•ŒνŒŒλ²³ 각각은 read(r), write(w), execute(x)λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€. λ˜ν•œ 3번 λ°˜λ³΅λ˜λŠ” μ΄μœ λŠ” μˆœμ„œλŒ€λ‘œ μœ μ €κΆŒν•œ(user), κ·Έλ£ΉκΆŒν•œ(group), κ·Έμ™Έ κΆŒν•œ(other)λ₯Ό μ˜λ―Έν•©λ‹ˆλ‹€. λ”°λΌμ„œ drwxrwxrwx의 μ˜λ―ΈλŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

  • d=> directory(폴더)이며
  • μ†Œμœ  μœ μ €κ°€ 읽고(r), μ“°κ³ (w), μ‹€ν–‰(x)을 ν•  수 있고
  • μœ μ €κ°€ μ†ν•œ 그룹이 읽고(r), μ“°κ³ (w), μ‹€ν–‰(x)을 ν•  수 있고
  • μ†Œμœ ν•œ μœ μ € μ΄μ™Έμ˜ μœ μ €κ°€  μ½κ³ (r), μ“°κ³ (w), μ‹€ν–‰(x)을 ν•  수 있음

μΆ”κ°€λ‘œ κ° bit 자리수λ₯Ό κ³„μ‚°ν•˜μ—¬ r κΆŒν•œ(4) w κΆŒν•œ(2) x κΆŒν•œ(1) = 총합 7둜 λ‚˜νƒ€λ‚Ό 수 있으며 이λ₯Ό μ΄μš©ν•˜μ—¬ κΆŒν•œ 섀정을 λ³€κ²½ν•  수 μžˆμŠ΅λ‹ˆλ‹€. κΆŒν•œ μ„€μ • 방법에 λŒ€ν•΄μ„œλŠ” μ•„λž˜μ—μ„œ μ–ΈκΈ‰ν•˜μ˜€μœΌλ‹ˆ μ°Έκ³ ν•˜μ‹œκΈ° λ°”λžλ‹ˆλ‹€.

2. 파일 κΆŒν•œ μ„€μ •

2.1 일반적인 파일 κΆŒν•œ μ„€μ •

일반적으둜 κΆŒν•œ μ„€μ • 방법은 chmodλ₯Ό μ΄μš©ν•˜μ—¬ μ§€μ •ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

$ chmod 777 /test
test 폴더에 rwxrwxrwx κΆŒν•œ λΆ€μ—¬

$ chmod +r /test
test 폴더에 rκΆŒν•œ λΆ€μ—¬

$ chmod -x /test
test 폴더에 xκΆŒν•œ 회수

그런데 이λ₯Ό 자주 μ‚¬μš©ν•˜λ‹€λ³΄λ©΄ νŠΉμ΄ν•œ κΆŒν•œμ„ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

$ ll / | grep tmp
drwxrwxrwt  38 root root      12288  1μ›” 26 12:12 tmp/

 μœ„μ—μ„œ λ³΄μ΄λŠ” κΆŒν•œμ˜ λ§ˆμ§€λ§‰ bitλŠ” t둜 μ•žμ—μ„œ μ–ΈκΈ‰ν•œ rwx에 ν•΄λ‹Ήν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. 이λ₯Ό sticky bit라 ν•˜λ©° 이와 λΉ„μŠ·ν•œ μœ ν˜•μ˜ κΆŒν•œμ„ 특수 κΆŒν•œμ΄λΌ ν•©λ‹ˆλ‹€. 

2.2 특수 κΆŒν•œ μ„€μ •

κΈ°μ‘΄ κΆŒν•œμ€ user, group, other μ΄λ ‡κ²Œ μ„Έκ°€μ§€λ‘œ λ‚˜λ‰˜μ–΄μ Έ 있죠? μ΄λ ‡κ²Œ λ‚˜λ‰œ κΆŒν•œ 쀑 νŠΉμ •ν•œ λ¬Έμžκ°€ λ“€μ–΄κ°€λ©΄ νŠΉμˆ˜ν•œ κΆŒν•œμ΄ λ§Œλ“€μ–΄μ§€λŠ”λ° νŠΉμˆ˜κΆŒν•œμ˜ μ’…λ₯˜λŠ” λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

2.2.1 SETUID

μΌμ‹œμ μΈ μ‚¬μš©μž κΆŒν•œμœΌλ‘œ μ†Œμœ μžλ§Œ μ ‘κ·Ό κ°€λŠ₯ν•œ νŒŒμΌμ— 일반 μœ μ €λ‘œ 접근이 ν•„μš”ν•  λ•Œ μ‚¬μš©ν•©λ‹ˆλ‹€. user 의 μ ‘κ·ΌκΆŒν•œ x μžλ¦¬μ— s κ°€ λŒ€μ‹  λ“€μ–΄κ°€λ©΄ setuid이며, λŒ€λ¬Έμž Sκ°€ λ“€μ–΄κ°€λ©΄ 일반 κΆŒν•œμ˜ -(μ ‘κ·Ό κΆŒν•œ μ—†μŒ)κ³Ό 같은 의미λ₯Ό κ°€μ§‘λ‹ˆλ‹€. κΆŒν•œ 섀정에 μžˆμ–΄μ„œ 맨 μ•žμ— 숫자 4λ₯Ό 뢙이면 μ„€μ •λ©λ‹ˆλ‹€.

  • e.g. rws rwx rwx (4777)

2.2.2 SETGID

μΌμ‹œμ μΈ κ·Έλ£Ή κΆŒν•œμœΌλ‘œ μ†Œμœ μžλ§Œ μ ‘κ·Ό κ°€λŠ₯ν•œ νŒŒμΌμ— 일반 μœ μ €λ‘œ 접근이 ν•„μš”ν•  λ•Œ μ‚¬μš©ν•©λ‹ˆλ‹€. group 의 μ ‘κ·ΌκΆŒν•œ x μžλ¦¬μ— s κ°€ λŒ€μ‹  λ“€μ–΄κ°€λ©΄ setgid이며, λŒ€λ¬Έμž Sκ°€ λ“€μ–΄κ°€λ©΄ 일반 κΆŒν•œμ˜ -(μ ‘κ·Ό κΆŒν•œ μ—†μŒ)κ³Ό 같은 의미λ₯Ό κ°€μ§‘λ‹ˆλ‹€. κΆŒν•œ 섀정에 μžˆμ–΄μ„œ λ§¨ μ•žμ— 숫자 2λ₯Ό 뢙이면 μ„€μ •λ©λ‹ˆλ‹€.

  • e.g. rwx rws rwx (2777)

2.2.3 STICKY BIT(t)

sticky bit(t) λŠ” λ‚˜ μ΄μ™Έμ˜ μœ μ € ν˜Ήμ€ 그룹에 κΆŒν•œμ΄ 뢀여됐을 λ•Œ, λ°œμƒν•  수 μžˆλŠ” 문제λ₯Ό ν•΄κ²°ν•˜κΈ° μœ„ν•œ bitμž…λ‹ˆλ‹€.

777κΆŒν•œμ˜ 폴더에 λͺ¨λ“  μ‚¬μš©μžλ“€μ΄ μ ‘κ·Όν•  수 있기 λ•Œλ¬Έμ—, λ‹€λ₯Έ μ‚¬μš©μžκ°€ μ‚¬μš©ν•˜λŠ” 것을 λͺ¨λ₯΄κ³  μ§€μš°κ²Œ λ˜λŠ” 일이 λ°œμƒν•  수 μžˆλ‹€. 이와 같은 ν˜„μƒμ„ λ°©μ§€ν•˜κΈ° μœ„ν•΄ sticky bit κ°œλ…μ΄ μƒκ²¨λ‚¬μŠ΅λ‹ˆλ‹€.

sticky bitλ₯Ό 디렉터리에 μ„€μ •ν•˜λ©΄ 디렉터리 내에 νŒŒμΌμ„ root와 νŒŒμΌμ†Œμœ μž(μƒμœ„ ν΄λ”μ˜ wκΆŒν•œμ„ κ°€μ§„ μ‚¬μš©μž)만 μ‚­μ œ κ°€λŠ₯ν•˜μ—¬, νŒŒμΌμ„ λ³΄ν˜Έν•˜κΈ° μœ„ν•œ λͺ©μ μœΌλ‘œ λ””λ ‰ν„°λ¦¬μ—λ§Œ μ„€μ • κ°€λŠ₯ν•©λ‹ˆλ‹€. μΌλ°˜μ μœΌλ‘œ λͺ¨λ“  μ‚¬μš©μžκ°€ μ ‘κ·Όν•  수 μžˆλŠ” /tmp /var/tmp 등이 sticky bit κΆŒν•œμœΌλ‘œ μ§€μ •ν•©λ‹ˆλ‹€.

  • e.g. rwx rwx rwt (1777)

2.3 κΆŒν•œ λΆ€μ—¬ μ˜ˆμ‹œ

$ chmod 1777 /test
$ chmod +t /test

μ΄λ ‡κ²Œ κΆŒν•œμ„ λΆ€μ—¬ν•˜λ©΄ μ•„λž˜μ™€ 같이 sticky bitκ°€ 적용된 것을 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

$ ls -ld /tmp
drwxrwxrwt 21 root root 12288 Apr 28 16:18 /tmp

μΆ”κ°€λ‘œ, linux κΈ°λ³Έ 디렉토리 쀑 sticky bitκ°€ 적용된 ν΄λ”λŠ” /tmp 와 /var/tmp μž…λ‹ˆλ‹€.

μ°Έκ³ 

  • [Blog] linux νŠΉμˆ˜κΆŒν•œ: https://websecurity.tistory.com/14
  • [Blog] κΈ°λ³Έ 디렉토리 μ„€μ • 및 κΈ°λŠ₯:  https://novice-data.tistory.com/32
  • [Blog] UNIX / Linux : What is the correct permission of /tmp and /var/tmp directories: https://www.thegeekdiary.com/unix-linux-what-is-the-correct-permission-of-tmp-and-vartmp-directories/  
λ°˜μ‘ν˜•
μ €μž‘μžν‘œμ‹œ λΉ„μ˜λ¦¬ λ³€κ²½κΈˆμ§€ (μƒˆμ°½μ—΄λ¦Ό)

'Study: ComputerScience(CS) > CS: Linux' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

[Linux] NVIDIA driver μ„€μΉ˜ (feat. μ„€μΉ˜μ‹œ 문제 λ°œμƒ 및 ν•΄κ²° 방법 포함)  (0) 2023.06.12
[Linux] X11 ν¬μ›Œλ”©ν•˜κΈ° (Ubuntu xserver, Window VcXsrv, MacOS XQuartz): μ„œλ²„/λ„μ»€μ—μ„œ QUI ν™•μΈν•˜κΈ°  (0) 2023.04.25
[Linux] gdb둜 λ””λ²„κΉ…ν•˜λŠ” 방법(feat. run/attach executable)  (0) 2022.12.29
[Linux] gdb ν™œμš©ν•˜λŠ” λ‹€μ–‘ν•œ 방법: executable, process, core dump file  (0) 2022.12.28
[Linux] λ¦¬λˆ…μŠ€ 크둠탭(Linux Crontab) μ‚¬μš©λ²•: μž‘μ—… μŠ€μΌ€μ€„λŸ¬  (0) 2022.12.14
    'Study: ComputerScience(CS)/CS: Linux' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€
    • [Linux] NVIDIA driver μ„€μΉ˜ (feat. μ„€μΉ˜μ‹œ 문제 λ°œμƒ 및 ν•΄κ²° 방법 포함)
    • [Linux] X11 ν¬μ›Œλ”©ν•˜κΈ° (Ubuntu xserver, Window VcXsrv, MacOS XQuartz): μ„œλ²„/λ„μ»€μ—μ„œ QUI ν™•μΈν•˜κΈ°
    • [Linux] gdb둜 λ””λ²„κΉ…ν•˜λŠ” 방법(feat. run/attach executable)
    • [Linux] gdb ν™œμš©ν•˜λŠ” λ‹€μ–‘ν•œ 방법: executable, process, core dump file
    DrawingProcess
    DrawingProcess
    과정을 그리자!

    ν‹°μŠ€ν† λ¦¬νˆ΄λ°”