inode 및 권한 명령에 대한 질문

inode 및 권한 명령에 대한 질문

이것이 사실인지 거짓인지 말해 줄 수 있는 사람이 있나요?

파일의 inode에 파일 내용이 포함된 블록의 주소가 있습니까?

또한Permission 명령의 경우 owner(r,w) g(r) 조건으로 기존 파일의 권한을 변경할 수 있는 권한이 있는지 묻는 질문이 있습니다. 그래서 나는 그것이 효과가 있을 것이라고 생각했지만 chmod 640 filename.txt분명히 chmod u+rw g+r filename.txt640만이 정확합니다. u+rw가 답변의 일부가 아닌 이유를 아는 사람이 있습니까?

답변1

귀하의 질문을 올바르게 이해한다면 상황에 따라 다르다고 말하고 싶습니다. Inode는 일반적으로 12개의 데이터 블록에 연결될 수 있습니다.Wikipedia 기사에서:

In the past, the structure may have consisted of eleven or thirteen 
pointers, but most modern file systems use fifteen pointers. These 
pointers consist of (assuming 15 pointers in the inode): 

- Twelve pointers that directly point to blocks of the file's data 
     (direct pointers) 
- One singly indirect pointer (a pointer that points to a block of 
     pointers that then point to blocks of the file's data) 
- One doubly indirect pointer (a pointer that points to a block of 
     pointers that point to other blocks of pointers that then point to 
     blocks of the file's data) 
- One triply indirect pointer (a pointer that points to a block of 
     pointers that point to other blocks of pointers that point to other 
     blocks of pointers that then point to blocks of the file's data)

따라서 파일이 12블록*(블록 크기) 미만인 한 Inode는 블록에 직접 연결됩니다. 파일이 12블록보다 큰 경우 간접 블록과 이중 간접 블록의 조합을 사용합니다.

                     inode 구조의 ss

다음을 사용하여 파일이 소비하는 블록 수를 확인할 수 있습니다 stat.

예제 stat 명령 #1

% stat /bin/ls
  File: `/bin/ls'
  Size: 117144      Blocks: 232        IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 2496176     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-04-17 16:24:20.593606056 -0400
Modify: 2010-11-03 07:43:02.000000000 -0400
Change: 2011-09-09 20:25:22.133239242 -0400

예제 stat 명령 #2

% stat /etc/httpd/conf/httpd.conf 
  File: `/etc/httpd/conf/httpd.conf'
  Size: 34417       Blocks: 72         IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 3147109     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-09-26 21:04:47.303641015 -0400
Modify: 2010-10-27 06:01:44.000000000 -0400
Change: 2010-12-18 19:30:00.719999998 -0500

chmod 문제

귀하의 질문에 대해서는 chmod다음과 같이 공백 대신 쉼표로 기호 권한(u+rg+r)을 구분해야 한다고 생각합니다.

% chmod u+rw,g+r filename.txt

인용하다

다음은 inode를 더 잘 이해하기 위해 읽을 수 있는 inode에 대한 몇 가지 추가 리소스입니다.

답변2

Inode는 일반적으로 직접 포인터를 사용하여 데이터 블록에 대한 포인터를 저장합니다. 이것이 충분하지 않다면 간접 포인터와 이중 간접 포인터를 사용하세요.

따라서 더 작은 파일(12블록)에서만 작동한다고 말할 수 있습니다.가지다파일 내용이 포함된 블록의 주소입니다.

답변3

예, inode에는 디스크에 있는 "호스팅된" 파일의 차단 목록이 포함되어 있습니다. 기본적으로 inode에는 파일에 대한 모든 정보가 포함되어 있습니다.와는 별개로이름 - 이 이름은 디렉토리(소위 "특수 파일")의 inode 번호와 "쌍을 이룹니다".

두 번째 질문에 대해 약간 불분명합니다. 파일의 소유자입니까? 귀하가 소유자라면, 파일의 권한을 변경할 수 있습니다.

이전에(umask) 권한을 어떻게 설정했느냐에 따라 맞을 수도 있고 틀릴 수도 있습니다. 너다음에 추가소유자에 대한 rw 권한과 그룹에 대한 읽기 권한이 있지만 삭제하지는 않습니다.기존의타인의 허가. 또한 실행 권한을 제거하지 않습니다. "="가 권한을 명시적으로 설정하기 때문에 "+"(또는 "-") 대신 "="를 사용하는 것이 좋습니다.

더 정확한 방법은 다음과 같습니다.

chmod u=rw,g=r,o= 파일

또는:

chmod a=,u+rw,g+r 파일(먼저 모든 권한을 비워두도록 설정)

이 경우 가장 쉬운 방법은 아마도 다음을 사용하는 것입니다.

chmod 640 파일

조금만 연습해 보면 8진수로 권한을 계산하는 것이 어렵지 않습니다.

관련 정보