❌이전글/이전글

CentOS7리눅스 lsattr, chattr 파일속성부여,변경

2019. 10. 29. 18:26
반응형

lsattr, chattr

 

이 명령어는 파일에 대한 특정한 속성(attribution)을 부여할 수 있습니다.

 

lsattr - 파일들의 속성을 출력

chattr - 속성 변경

 

명령어 속성 추가/삭제 설명
chattr +i 파일 속성 i 속성 추가
chattr -i 파일 속성 i 속성 삭제
i속성 i속성을 가지는 파일은 슈퍼유저라도 변경 삭제 등 조작 불가능(immutable)
chattr +a 파일 속성 a 속성 추가
chattr -a 파일 속성 a 속성 삭제
a속성 a속성을 가지는 파일은 내용추가 가능, 슈퍼유저라도 삭제는 불가능(append only)

i 속성 테스트

[root@localhost ~]# mkdir /testdir

[root@localhost ~]# cd /testdir

[root@localhost testdir]# ll

total 0

[root@localhost testdir]# touch testfile

[root@localhost testdir]# ll

total 0

-rw-r--r-- 1 root root 0 2019-10-29 16:07 testfile

[root@localhost testdir]# lsattr testfile                  #testfile의 속성 default
---------------- testfile

[root@localhost testdir]# chattr +i testfile             #testfile i 속성 추가

----i----------- testfile

[root@localhost testdir]# rm testfile

rm: remove regular empty file ‘testfile’? y
rm: cannot remove ‘testfile’: Operation not permitted  

#root유저여도 삭제 불가능, 삭제하기 위해서는 chattr -i 로 명령어로 i속성을 제거해줘야 함 

 

 

a 속성 테스트

 

[root@localhost testdir]# touch testfile2
[root@localhost testdir]# lsattr testfile2
---------------- testfile2

[root@localhost testdir]# chattr +a testfile2

[root@localhost testdir]# lsattr testfile2
-----a---------- testfile2                                                  #a속성 추가

[root@localhost testdir]# echo "test attribution" >> testfile2
[root@localhost testdir]# echo "test attribution" >> testfile2  #a속성은 내용은 추가가능
[root@localhost testdir]# cat testfile2
test attribution
test attribution

[root@localhost testdir]# rm testfile2
rm: remove regular file ‘testfile2’? y
rm: cannot remove ‘testfile2’: Operation not permitted

#a속성을 가진 파일도 삭제 불가능 , 삭제하기 위해선 a속성을 제거 후 삭제 시켜줘야한다

 

 

참고

 

[root@localhost testdir]# mkdir testdir
[root@localhost testdir]# ll

total 4
drwxr-xr-x 2 root root  6 2019-10-29 18:18 testdir
-rw-r--r-- 1 root root  0 2019-10-29 16:07 testfile
-rw-r--r-- 1 root root 34 2019-10-29 18:14 testfile2

[root@localhost testdir]# chattr +i testdir
[root@localhost testdir]# lsattr
----i----------- ./testfile
-----a---------- ./testfile2
----i----------- ./testdir
[root@localhost testdir]# rmdir testdir
rmdir: failed to remove ‘testdir’: Operation not permitted

디렉토리도 가능하다

더 자세한 내용은 man chattr로 확인 가능합니다

기회가 된다면 후에 더 많은 옵션들의 기능을 확인하여 포스팅하겠습니다.

반응형
저작자표시 동일조건 (새창열림)

'❌이전글 > 이전글' 카테고리의 다른 글

랜LAN통신 ARP Request Reply  (0) 2019.12.02
시스코 스위치Switch 기능 5가지  (4) 2019.12.02
시스코 스위치, 라우터 내부구조 RAM ROM NVRAM Flash Memory  (2) 2019.11.28
리눅스centos7 - su, su - 차이점확인  (2) 2019.10.29
VPN(Virtual Private Network) 가상사설망에 대해 알아보자  (0) 2019.10.17
EVE-NG XSHELL 등록  (0) 2019.10.14
자바JAVA - 배열 사용 array  (2) 2019.10.13
쉘스크립트 bash 쉘 작성과 실행  (0) 2019.10.12
'❌이전글/이전글' 카테고리의 다른 글
  • 시스코 스위치, 라우터 내부구조 RAM ROM NVRAM Flash Memory
  • 리눅스centos7 - su, su - 차이점확인
  • VPN(Virtual Private Network) 가상사설망에 대해 알아보자
  • EVE-NG XSHELL 등록
당근은싫지만먹어야함
당근은싫지만먹어야함
공부한거 대충 끄적이는 블로그...
반응형
당근은싫지만먹어야함
정보의 게이트웨이
당근은싫지만먹어야함
전체
오늘
어제
  • 분류 전체보기 (111)
    • 🐍JAVA (1)
    • 🐍ORACLE (3)
    • ❌이전글 (107)
      • 이전글 (107)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • centos
  • 티스토리
  • 스위치
  • 오라클
  • SQL
  • 운영체제
  • 우분투
  • 셸스크립트
  • 센트오에스7
  • 네트워크
  • centos7
  • dns
  • 디비버
  • oracle
  • 리눅스
  • 윈도우10
  • Linux
  • 자바
  • EVE-NG
  • RAID구성

최근 댓글

최근 글

hELLO · Designed By 정상우.
당근은싫지만먹어야함
CentOS7리눅스 lsattr, chattr 파일속성부여,변경
상단으로

티스토리툴바

개인정보

  • 티스토리 홈
  • 포럼
  • 로그인

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.