!["sudo chmod +w /etc/hosts"를 실행할 수 없습니다.](https://linux55.com/image/51025/%22sudo%20chmod%20%2Bw%20%2Fetc%2Fhosts%22%EB%A5%BC%20%EC%8B%A4%ED%96%89%ED%95%A0%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
ESXi
사용자 xyz(사용됨)로 원격 가상 머신에 로그인했습니다. /etc/hosts
기본적으로 표시되지 않는 일부 네트워크 이름을 추가하기 위해 내 네트워크 이름을 변경하고 싶습니다 .
처음으로 달리려고 했는데
sudo vi /etc/hosts
하지만 를 입력하면 vi
파일이 읽기 전용이라는 메시지가 계속 표시됩니다. 다음과 같은 권한이 있습니다.
>ls -l /etc/hosts
-rw-r--r-- 1 root root 416 2013-06-19 08:08 /etc/hosts
또한 거의 모든 다른 파일 /etc
에는 .lsattr
-----------------e-
hosts
----i------------e-
>lsattr /etc
...
-----------------e- ./python
----i------------e- ./hosts
...
그런 다음 나는 이것을 시도했고 chmod
이것이 내가 얻은 것입니다.
>sudo chmod +w /etc/hosts
chmod: changing permissions of `/etc/hosts': Operation not permitted
sudo
루트(루트로 전환할 때 )는 모든 것을 할 수 있어야 하기 때문에 이것이 이상하다고 생각합니다 . 내 sudoers
파일은 매우 평범해 보입니다.
1 # /etc/sudoers
2 #
3 # This file MUST be edited with the 'visudo' command as root.
4 #
5 # See the man page for details on how to write a sudoers file.
6 #
7
8 Defaults env_reset
9
10 # Host alias specification
11
12 # User alias specification
13
14 # Cmnd alias specification
15
16 # User privilege specification
17 root ALL=(ALL) ALL
18
19 # Allow members of group sudo to execute any command after they have
20 # provided their password
21 # (Note that later entries override this, so you might need to move
22 # it further down)
23 %sudo ALL=(ALL) ALL
24 #
25 #includedir /etc/sudoers.d
26
27 # Members of the admin group may gain root privileges
28 %admin ALL=(ALL) ALL
이런 일이 발생하는 이유와 해결 방법에 대한 설명을 찾고 있습니다.
답변1
이 문제의 구체적인 속성은 다음 i
과 같습니다.불변속성.
파일이 표시되었습니다.불변.
이는 루트를 포함한 어떤 사용자도 이를 변경할 수 없음을 의미합니다. 루트는 여전히 속성을 변경하고 변경할 수 없는 속성을 삭제할 수 있지만 루트가 단순히 무시할 수 있는 파일에 대한 표준 쓰기 금지 권한과 달리 파일을 변경하기 전에 그렇게 해야 합니다.
내가 아는 한, 이러한 속성은 ext[234] 파일 시스템에만 적용됩니다.
chattr의 매뉴얼 페이지를 확인할 수 있습니다.
$man chattr
사용 가능한 속성의 전체 목록과 설명을 확인하세요.
내가 실제로 사용한 유일한 것은 i입니다. 그러나 다른 것들은 다음과 같습니다:
A: atime remains unmodified when accessed
a: can only be opened for writing in append-only mode
c: compressed automatically
j: all data is written to the journal before being written to the file
s: blocks are zeros when file is deleted
u: contents of file are saved when file is deleted for later undelete
다른 속성도 있지만 약간 난해하며 chattr 매뉴얼 페이지에서 더 많은 정보를 찾을 수 있습니다.
답변2
제거하기 위해 확장 속성을 변경했는데 i
괜찮았습니다.
>sudo chattr -i /etc/hosts
lsattrs
하지만 여전히 내가 변경한 속성을 포함하여 출력을 읽는 방법을 설명하고 싶습니다 .