1) 권한 기본

nojeans@ubuntu-22-04:~$ ls -al perm.txt
-rw-rw-r-- 1 nojeans nojeans 0 Apr  2 17:04 perm.txt

nojeans@ubuntu-22-04:~$ echo "hi" > perm.txt # output redirection
## echo => "display text"

nojeans@ubuntu-22-04:~$ ls
perm.txt
nojeans@ubuntu-22-04:~$ cat perm.txt
hi

<aside> ✅ ***- | rwxr-xr-- | 1 | nojeans nojeans | 3 | Apr 2 17:06 | perm.txt

  1. type (파일이면 -이고, 디렉토리면 d)
  2. access mode (소유자, 그룹, 기타 사용자 ⇒ other) r ⇒ read (예를 들면 → nano, cat 통하여 읽기), w ⇒ write, x ⇒ execute
  3. owner, group (소유자, 그룹)***

</aside>

2) 권한을 변경하는 방법 - chmod

<aside> ✅ - | rwxr-xr-- | 1 | nojeans nojeans | 3 | Apr 2 17:06 | perm.txt ← “Access Mode” → ⇒ 변경하기 위하여 “chmod” 이용 !!!

</aside>

chmod o-r # 기타 사용자의 읽기 권한 삭제
chmod o+r # 기타 사용자의 읽기 권한 추가

>> 소유자 -> u (user)
>> 그룹 -> g (group)
>> 기타 사용자 -> o (other)

3) 실행의 개념과 권한 설정 - execute

nojeans@xudegloss:~$ chmod u+x hi-machine.sh
nojeans@xudegloss:~$ ls -l
total 4
-rwxrw-r-- 1 nojeans nojeans 31 Apr 12 00:13 hi-machine.sh

nojeans@xudegloss:~$ ./hi-machine.sh # 현재 위치에 존재하는 sh 파일 실행
hi hi hi hi
nojeans@xudegloss:~$ ls -l
total 4
-rwxrw-r-- 1 nojeans nojeans 31 Apr 12 00:13 hi-machine.sh

nojeans@xudegloss:~$ chmod u-x hi-machine.sh

**nojeans@xudegloss:~$ /bin/bash hi-machine.sh # /bin/bash는 실행 권한 없어도 됨
hi hi hi hi**

1) sh 파일 실행시킬 때, 운영체제는 제일 먼저 “파일이 현재 사용자에게 실행 가능한지” 여부 판단

2) 실행 가능하다면, # 뒤에 있는 /bin/bash 구동 → sh 파일 전달

3) sh 파일의 결과를 출력