| info | |
|---|---|
| name | sudoedit |
| full name | sudoedit |
| aliases | sudoedit |
| tags | sudoedit |
권한이 필요한 파일을 직접 root 권한 editor로 열지 않고, 임시 복사본 편집 후 안전하게 반영하는 sudo의 edit mode.
sudoedit는 실제 editor를 target user 권한이 아니라 invoking user 환경으로 실행하고, 수정 결과만 원본 파일에 반영한다.sudo vim /etc/file 보다 안전한 선택지로 취급된다.sudo -e와 같은 의미로 동작한다.man sudoedit 기준으로 정리했다.sudoedit /etc/hosts sudoedit /etc/ssh/sshd_config sudoedit -u root /etc/fstab sudoedit -n /etc/sudoers sudo -e /etc/hosts
sudoedit FILE…sudoedit -u USER FILE…sudoedit -n FILE…sudo -e FILE…-u USER: 기본 target user 대신 다른 user 기준으로 파일 권한 검사를 수행한다.-n: password prompt를 띄우지 않는다. 인증이 필요하면 즉시 실패한다.-S: password를 terminal 대신 stdin에서 읽는다.-A: askpass helper를 사용한다.-p PROMPT: custom password prompt를 지정한다.-T TIMEOUT: command timeout을 지정한다. policy가 허용해야 한다.-D DIR: editor 실행 전 working directory를 바꾼다.-R DIR: chroot directory를 지정한다.-C NUM: 지정한 fd 이상을 닫는다. policy 제한을 받는다.-h: short help를 출력한다.–: 뒤 인자를 path로만 해석한다.sudoedit /etc/hosts sudoedit /etc/ssh/sshd_config EDITOR=nvim sudoedit /etc/fstab SUDO_EDITOR="code --wait" sudoedit /etc/hosts sudoedit -n /etc/hosts sudo -e /etc/cron.d/app
$SUDO_EDITOR → $VISUAL → $EDITORsudoers의 editor 설정을 따른다.sudoedit는 editor를 invoking user 환경으로 실행하므로, root 전용 shell rc나 root home에 의존하는 workflow와는 다르게 동작할 수 있다.sudoedit: command not found 또는 별도 binary가 없으면 보통 sudo -e로 같은 동작을 사용할 수 있다.sudoedit 자체가 ownership 또는 setuid 오류를 내면 sudo package 설치 상태가 깨졌을 가능성이 크다.sudoedit는 사실상 sudo front-end의 edit mode다.sudoers 설정에 따라 허용 옵션과 password 동작이 달라질 수 있다.sudo vim /etc/file 형태로 여는 방식은 plugin, swap, backup, shell escape 관점에서 더 위험할 수 있다.sudoedit가 있는 환경에서는 config file 수정에 edit mode를 우선 고려하는 편이 안전하다.sudo -e는 sudoedit와 같은 의미다.visudo 같은 전용 validator와 함께 쓰는 편이 낫다.–wait 성격의 옵션이 필요할 수 있다.