OS/LINUX

immutable file in linux

卽興詩人 2014. 10. 29. 12:15

linux 에는 Immutable file 즉 변경/삭제가 불가능한 파일이 있다


immutable file 은 root 권한으로도 수정/삭제가 불가능하다.


immutale file 은


root@server :~# touch example.txt


같은 명령어를 입력했을때


touch: cannot touch `example.txt': 허가 거부


혹은


Operation not permitted”


이런식으로 허가 거부가 떨어지고


root@server :~# lsattr example.txt


lsattr 명령으로 확인시에


----i--------e- example.txt


위와같이 ----i---- 로 immutable 표시되는 것을 확인할 수 있다


그럼 특정 작업중에 필수적으로 설정을 바꿔야 하는 파일인데 immutable file 일때는 어떻게 해야할까


chattr -i example.txt 


root 권한으로 접근후 


chattr -i 명령으로 i 를 제거해주면 된다


그럼 다시 i 를 포함하고 싶다면


아래와같이 + 명령으로 포함시킬수 있다.


chattr +i example.txt