VIM 사용하다가 저장시 root 계정이 없다고 뜬다면?

리눅스/MAC 에서

vi /etc/hosts 와 같이 시스템 파일을 건들고, 열심히 수정을 하였습니다. 그런데 만약 sudo 명령어를 잊고 실행시켰다는 것을 알았다면?  다시 작성할까…. 고민하시는 분들을 위한 꿀팁입니다.

:는 명령어 내린다는 것을 다들 알것이고, w 는 저장입니다. 이에 뒤붙여서 !sudo tee % 하면 비밀번호 입력하라고 합니다. 비번입력하면 신기하게 저장됩니다.

:w !sudo tee %

이제 파일 다시 수정하지 마세요.

MAC 에서도 적용되는 내용입니다.

오늘은 여기까지.

“VIM 사용하다가 저장시 root 계정이 없다고 뜬다면?”에 대한 42개의 댓글

  1. This design is incredible! You obviously know how to keep
    a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Great job.
    I really enjoyed what you had to say, and more
    than that, how you presented it. Too cool!

  2. Simply wish to say your article is as surprising.
    The clearness in your post is simply great and i can assume you are knowledgeable in this subject.
    Fine together with your permission allow me to grasp your feed to keep up to date with forthcoming post.
    Thank you one million and please carry on the gratifying work.

  3. I’m very happy to find this web site. I need
    to to thank you for your time for this particularly fantastic read!!
    I definitely loved every bit of it and i also have you bookmarked to check out new information in your blog.

  4. This design is steller! You most certainly know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.

    I really enjoyed what you had to say, and more than that,
    how you presented it. Too cool!

답글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다.