chattr
Original author(s) | Remy Card |
---|---|
Operating system | Linux |
Platform | Cross-platform |
Type | Command |
Operating system | BSD-like systems, including macOS |
---|---|
Platform | Cross-platform |
Type | Command |
chattr은 사용자에게 파일의 특정 속성을 설정하는 것을 허용하는 리눅스의 명령입니다. lsattr는 파일의 속성을 표시하는 명령입니다.
macOS를 포함한 대부분의 BSD-계열 시스템은 항상 속성을 설정하는 유사한 명령 chflags을 가지지만, 속성을 표시하기 위한 명령은 없었습니다; ls 명령에 대한 특정 옵션이 대신 사용됩니다. chflags 명령은 4.4BSD에서 처음 등장했습니다.
Solaris는 특별히 조작하기 위한 명령을 가지지 않습니다. chmod[1] 및 ls[2]가 대신 사용됩니다.
일반적으로 다른 유닉스는 유사한 명령을 가지지 않습니다. 비슷하게 들리는 명령 chatr (HP-UX에서) 및 lsattr (AIX에서)이 있지만 관련되지 않은 기능을 가집니다.
무엇보다도, chattr 명령은 암호 파일과 특정 시스템 파일이 소프트웨어 업그레이드 동안 지워질 수 없도록 파일을 변경할 수 없도록 하는 데 유용합니다.[3]
In Linux systems (chattr and lsattr)
File system support
명령줄 도구 chattr (속성 조작) 및 lsattr (속성 나열)은 원래 Second Extended Filesystem 제품군 (ext2, ext3, ext4)에 고유했었고, e2fsprogs 패키지의 일부로 사용할 수 있습니다.
어쨌든, 그 이후로 기능은 XFS, ReiserFS, JFS 및 OCFS2를 포함한 다른 많은 시스템으로 전체 또는 부분적으로 확장되었습니다. btrfs 파일 시스템은 CoW와 결합된 느린 성능으로 인해 btrfs의 기본 제공 Copy-On-Write (CoW) 기능을 끄는 C
플래그를 비롯한 속성 기능을 포함합니다.
chattr description
chattr 명령의 형식은 다음입니다:
chattr [-RVf] [-+=AacDdijsTtSu] [-v version] files...
-R
– 디렉토리와 그 내용의 속성을 재귀적으로 변경합니다.-V
– 프로그램 버전을 장황하게 하고 인쇄합니다.-f
– 대부분의 오류 메시지를 억제합니다.
lsattr description
lsattr 명령 (gnu 1.41.3)의 형식은 다음입니다:
lsattr [ -RVadv ] [ files... ]
-R
– 디렉토리의 속성과 그 내용을 재귀적으로 나열합니다.-V
– 프로그램 버전을 표시합니다.-a
– dotfiles을 포함하여 디렉토리 안의 모든 파일을 나열합니다.-d
– 내용을 나열하지 않고 다른 파일과 같은 디렉토리를 나열합니다.
Attributes
일부 속성은 다음을 포함합니다:
속성 | lsattr 플래그 | chattr 옵션 | 의미와 근거 |
---|---|---|---|
No atime updates
|
A
|
+A to set-A to clear
|
|
Append only | a
|
+a to set-a to clear[note 1]
|
|
Compressed | c
|
+c to set-c to clear[note 2]
|
|
No Copy-on-Write (CoW) | C
|
+C to set-C to clear[note 3]
|
|
Synchronous directory updates | D
|
+D to set-D to clear
|
|
No dump | d
|
+d to set-d to clear
|
|
Compression error | E
|
(unavailable) |
|
Extent format | e
|
(unavailable) |
|
Huge file | h
|
(unavailable) |
|
Indexed directory | I
|
(unavailable) |
|
Immutable | i
|
+i to set-i to clear[note 1]
|
|
Data journaling | j
|
+j to set-j to clear[note 4]
|
|
Secure deletion | s
|
+s to set-s to clear[note 2][note 5]
|
|
Synchronous updates | S
|
+S to set-S to clear
|
|
Top of directory hierarchy | T
|
+T to set-T to clear
|
|
No tail-merging | t
|
+t to set-t to clear
|
|
Undeletable | u
|
+u to set-u to clear[note 2]
|
|
Compression raw access | X
|
(unavailable) |
|
Compressed dirty file | Z
|
(unavailable) |
|
Version / generation number | -v
|
-v version
|
|
Notes
- ^ a b Only the superuser or a process possessing the
CAP_LINUX_IMMUTABLE
capability can set or clear these attributes. - ^ a b c These attributes are not honored by the ext2 and ext3 filesystems as implemented in the current mainline Linux kernels.
- ^ These attributes only make sense for Copy-on-Write file-systems such as btrfs.
- ^ Only the superuser or a process possessing the
CAP_SYS_RESOURCE
capability can set or clear this attribute. - ^ This attribute is not honored by the ext4 filesystem as implemented in the current mainline Linux kernels as reported in Bug #17872.
In BSD-like systems (chflags)
File system support
chflags 명령은 특정 파일 시스템을 지정하지 않습니다. BSD 시스템에서 UFS와 macOS에서 APFS, HFS+, SMB, AFP, 및 FAT는 가장 작게 일부 프래그를 지원합니다.
chflags description
chflags 명령의 형식은 다음과 같습니다:
chflags [-R [-H | -L | -P]] flags file ...
-H
– 만약 -R 옵션이 지정되면, 명령줄에 대한 심볼릭 링크를 따릅니다. (트리 순회에서 만난 심볼릭 링크는 따르지 않습니다.)-L
– 만약 -R 옵션이 지정되면, 모든 심볼릭 링크가 뒤따릅니다.-P
– 만약 -R 옵션이 지정되면, 심볼릭 링크는 뒤따르지 않습니다. 이것이 기본값입니다.-R
– 파일 자체가 아니라 파일에 뿌리를 둔 파일 계층에 대한 파일 플래그를 변경합니다.
Displaying
일반적으로 BSD-계열 시스템은 파일의 플래그를 표시하기 위해 기본 사용자-수준 명령이 없습니다. ls 명령은 전달된 시스템, 플래그에 따라 -lo
, 또는 -lO
플래그와 함께 수행할 것입니다.
Attributes
모든 전통적인 속성은 수퍼유저에 의해 설정되거나 지워질 수 있습니다; 일부는 파일 소유자에 의해 설정되거나 지워질 수도 있습니다. 일부 속성은 다음을 포함합니다:
속성 | ls 플래그 | chflags 플래그 | 소유자-설정가능 | OS 지원 | 의미와 근거 |
---|---|---|---|---|---|
Archived | arch | arch, archived | No | All | 파일이 보관됩니다 |
Opaque | opaque | opaque | Yes | All | 유니온 마운트를 통해 볼 때 디렉토리가 불투명합니다. |
No dump | nodump | nodump | Yes | All | 파일이 덤프되지 않습니다. |
System append-only | sappnd | sappnd, sappend | No | All | 파일에저 존재하는 데이터는 덮어쓸 수 없고 파일은 잘려질 수 없습니다. |
User append-only | uappnd | uappnd, uappend | Yes | All | 파일에서 존재하는 데이터는 덮어쓸 수 없고 파일은 잘려질 수 없습니다. |
System immutable | schg | schg, schange, simmutable | No | All | 파일은 변경되거나, 이름 변경되거나, 이동되거나, 제거될 수 없습니다. |
User immutable | uchg | uchg, uchange, uimmutable | Yes | All | 파일은 변경되거나, 이름 변경되거나, 이동되거나, 제거될 수 없습니다. |
System no-unlink | sunlnk | sunlnk, sunlink | No | All | 파일은 제거되거나, 이름 변경되거나 마운트되지 않습니다; macOS에서 이 플래그는 단일 사용자 모드에서 설정하거나 지워져야 합니다. |
User no-unlink | uunlnk | uunlnk, uunlink | Yes | Some | 파일은 제거되거나, 이름 변경되거나 마운트될 수 없습니다; macOS에 의해 지원되지 않습니다. |
Hidden | hidden | hidden | No | FreeBSD | 파일은 기본적으로 GUI에서 숨겨져 있습니다 (그러나 ls에서는 아닙니다). |
User hidden | uhidden | uhidden | Yes | FreeBSD | 파일은 기본적으로 GUI에서 숨겨져 있습니다 (그러나 ls에서는 아닙니다). |
Hidden | hidden | hidden | Yes | macOS | File is hidden by default in the GUI (but not in ls) |
Tracked | tracked | tracked | Yes | macOS | 파일 수정과 삭제는 추적됩니다. |
Restricted | restricted | restricted | No | macOS | 파일은 시스템 무결성 보호에 의해 보호됩니다; 확장 속성 com.apple.rootless와 동반됩니다; 플래그는 복구 모드에서 설정되거나 지워져야 합니다. |
Compressed | compressed | No | macOS | 파일이 HFS-압축 (읽기 전용 플래그)입니다; APFS-포맷 볼륨에서는 사용할 수 없습니다 | |
Data Vault | No | macOS | macOS Mojave 이후 숨겨진 개인 정보 플래그는 코어 시스템에서 특별한 권한 없이 접근을 금지하도록 설정했습니다. |
BSD 시스템은 offline, snapshot, sparse,[4] 및 uarchive와 같은 추가적인 플래그를 제공합니다; 참조를 참조하십시오.
See also
ATTRIB
– analogous command in MS-DOS, OS/2 and Microsoft Windowschown
– change file/directory ownership in a Unix systemchmod
– change file access control attributes in a Unix systemcacls
– change file access control lists in Microsoft Windows NT
Notes
- ^ illumos and OpenSolaris User Commands Reference Manual from latest Sun based OpenSolaris –
- ^ illumos and OpenSolaris User Commands Reference Manual from latest Sun based OpenSolaris –
- ^ OpenBSD General Commands Manual –
- ^ Different from the APFS sparse files on macOS, which have no special flags.
References
- Linux User Commands Manual –
- Linux User Commands Manual –
- OpenBSD General Commands Manual –
- FreeBSD General Commands Manual –
- NetBSD General Commands Manual –
- Darwin and macOS General Commands Manual (outdated; see newer version) –
- stat.h (flags section in the BSD system source code of the macOS XNU kernel)