Linux 특수 파일

mohadang·2023년 3월 11일
0

Linux System Programming

목록 보기
4/9
post-thumbnail

파일 종류 문자

- : 일반 파일
d : 디렉토리
b : 블록 장치 특수 파일
c : 문자 장치 특수 파일
l : 심볼릭 링크

특수 파일(Special file)

파일 형태로 표현된 커널 내 객체, 즉 OS의 자원이다.
유닉스 시스템은 OS 자원을 파일 형태로 표현하고 있다.
OS 자원이라고 함은 디스크, CPU, 네트워크, RAM 등을 말한다.
리눅스에서 이런 자원에 데이터 전송, 장치 접근 시 사용하는 파일을 특수 파일이라고 한다

device files, pipes, socket, ...

특수 파일은 장치와 데이터를 주고 받는 통로이다 데이터 블록이 없으며(디스크에 저장 X) 장치 번호를 inode에 저장한다.
모니터나 프린터 역시 특수 파일을 통해 데이터를 주고 받는다.

디바이스는 반드시 HW를 말하는것이 아니다 SW적인 디바이스도 있따.

character device file(c)

character 단위로 데이터 전송

block device file(b)

block 단위로 데이터를 전송

major device number, minor device numger

major device number : 장치의 종류(monitor, printer, ...)
minor device number : 장치의 수

red@DESKTOP-G15ND3V:~$ ls -l /dev/
total 0
crw------- 1 root root   5,   1 <-- major, minor ...
crw-r--r-- 1 root root  10, 235 Mar 11 10:09 autofs
drwxr-xr-x 2 root root       40 Mar 11 10:09 block
drwxr-xr-x 2 root root      100 Mar 11 10:09 bsg
crw------- 1 root root  10, 234 Mar 11 10:09 btrfs-control
drwxr-xr-x 3 root root       60 Mar 11 10:09 bus

major, minor는 각각 major device number와 minor device numger이다

File access permission

총 9bit이다.

  • rwxrwxrwx
  • 앞에서 부터 소유자, 그룹, 기타 사용자 접근 권한이다.
    기본적으로 파일을 생성한 사용자의 소유자와 소유자가 포함된 그룹으로 설정된다.
red@DESKTOP-G15ND3V:~$ vim test_file
red@DESKTOP-G15ND3V:~$ ls -al test_file
-rw-r--r-- 1 red red 6 Mar 11 14:22 test_file
red@DESKTOP-G15ND3V:~$ whoami
red
profile
mohadang

0개의 댓글