본문 바로가기
Linux

linux command - attr

by 도경다경 2023. 5. 13.
반응형

attr 커맨드 설명은 XFS filesystem 객체에 확장 속성 추가라고 심플하게 설명되어 있다.
그런데 문제는 확장 속성이 무엇인지는 명쾌하게 설명하지 못하고 있다.

public cloud를 공부했다면 tag 라는 기능을 알 것이다.
결론적으로 말하면 XFS filesystem(이하 파일, 디렉토리도 가능) 에 tag 처럼 확장 속성을 넣어서 활용할 수 있게 하겠다는거다.

예를 들어 /APP 파일시스템(xfs) 에 

# attr /APP

수행하면 아무것도 출력되지 않는다. 기본은 아무 확장속성이 부여되지 않았기 때문이다.
속성과 속성에 해당하는 값을 test로 넣어보자.

# attr -s test_attr_name -V test_value /APP
Attribute "test_attr_name" set to a 10 byte value for /APP:
test_vaule

값이 입력된다.
이제 잘 설정되어 있는지 출력해보자.

# attr -l /APP
Attribute "test_attr_name" had a 10 byte value for /APP

속성 이름만 리스트(-l : 파일시스템에 할당된 속성명 전체 리스트) 되고 속성값은 보이지 않는다.
속성값을 보려면 다음과 같이 실행한다.

# attr -g test_attr_name /APP
Attribute "test_attr_name" had a 10 byte value for /APP:
test_value

대충 눈치챘겠지만 -s 가 set, -g 가 get 이다. 리눅스는 가독성이 참 좋다.

tag를 사용해 본 적이 있다면 tag를 기준으로 그룹화하여 관리가 가능한 것을 알 것이다.
하지만 굳이? 

NAME

       attr - extended attributes on XFS filesystem objects

SYNOPSIS

       attr [ -LRSq ] -s attrname [ -V attrvalue ] pathname

       attr [ -LRSq ] -g attrname pathname

       attr [ -LRSq ] -r attrname pathname

       attr [ -LRSq ] -l pathname

OVERVIEW

       Extended attributes implement the ability for a user to attach
       name:value pairs to objects within the XFS filesystem.

       This document describes the attr command, which is mostly
       compatible with the IRIX command of the same name.  It is thus
       aimed specifically at users of the XFS filesystem - for
       filesystem independent extended attribute manipulation, consult
       the getfattr(1) and setfattr(1) documentation.

       Extended attributes can be used to store meta-information about
       the file.  For example "character-set=kanji" could tell a
       document browser to use the Kanji character set when displaying
       that document and "thumbnail=..." could provide a reduced
       resolution overview of a high resolution graphic image.

       In the XFS filesystem, the names can be up to 256 bytes in
       length, terminated by the first 0 byte.  The intent is that they
       be printable ASCII (or other character set) names for the
       attribute.  The values can be up to 64KB of arbitrary binary
       data.

       Attributes can be attached to all types of XFS inodes: regular
       files, directories, symbolic links, device nodes, etc.

       XFS uses 2 disjoint attribute name spaces associated with every
       filesystem object.  They are the root and user address spaces.
       The root address space is accessible only to the superuser, and
       then only by specifying a flag argument to the function call.
       Other users will not see or be able to modify attributes in the
       root address space.  The user address space is protected by the
       normal file permissions mechanism, so the owner of the file can
       decide who is able to see and/or modify the value of attributes
       on any particular file.
반응형

'Linux' 카테고리의 다른 글

linux command - bc  (0) 2023.05.17
linux command - basename  (0) 2023.05.17
linux command - apropos  (1) 2023.05.12
linux command - alias  (0) 2023.05.12
linux command - ac  (0) 2023.05.12

댓글