문서 보기이전 판역링크맨 위로 이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요. {{tag>[cli sudo security editor]}} ====== sudoedit ====== 권한이 필요한 파일을 직접 root 권한 editor로 열지 않고, 임시 복사본 편집 후 안전하게 반영하는 ''sudo''의 edit mode. ===== Summary ===== * ''sudoedit''는 실제 editor를 target user 권한이 아니라 invoking user 환경으로 실행하고, 수정 결과만 원본 파일에 반영한다. * 일반적으로 system config를 수정할 때 ''sudo vim /etc/file'' 보다 안전한 선택지로 취급된다. * 실행 시 내부적으로 ''sudo -e''와 같은 의미로 동작한다. * 이 페이지의 동작 설명은 로컬 ''man sudoedit'' 기준으로 정리했다. ===== Usage ===== <code bash> sudoedit /etc/hosts sudoedit /etc/ssh/sshd_config sudoedit -u root /etc/fstab sudoedit -n /etc/sudoers sudo -e /etc/hosts </code> * ''<color #c3c3c3>**sudoedit**</color> <color #7092be>FILE...</color>'' * ''<color #c3c3c3>**sudoedit**</color> <color #22b14c>**-u**</color> <color #7092be>USER</color> <color #7092be>FILE...</color>'' * ''<color #c3c3c3>**sudoedit**</color> <color #22b14c>**-n**</color> <color #7092be>FILE...</color>'' * ''<color #c3c3c3>**sudo**</color> <color #22b14c>**-e**</color> <color #7092be>FILE...</color>'' ===== Options ===== * ''<color #22b14c>**-u**</color> <color #7092be>USER</color>'': 기본 target user 대신 다른 user 기준으로 파일 권한 검사를 수행한다. * ''<color #22b14c>**-n**</color>'': password prompt를 띄우지 않는다. 인증이 필요하면 즉시 실패한다. * ''<color #22b14c>**-S**</color>'': password를 terminal 대신 stdin에서 읽는다. * ''<color #22b14c>**-A**</color>'': askpass helper를 사용한다. * ''<color #22b14c>**-p**</color> <color #7092be>PROMPT</color>'': custom password prompt를 지정한다. * ''<color #22b14c>**-T**</color> <color #7092be>TIMEOUT</color>'': command timeout을 지정한다. policy가 허용해야 한다. * ''<color #22b14c>**-D**</color> <color #7092be>DIR</color>'': editor 실행 전 working directory를 바꾼다. * ''<color #22b14c>**-R**</color> <color #7092be>DIR</color>'': chroot directory를 지정한다. * ''<color #22b14c>**-C**</color> <color #7092be>NUM</color>'': 지정한 fd 이상을 닫는다. policy 제한을 받는다. * ''<color #22b14c>**-h**</color>'': short help를 출력한다. * ''<color #22b14c>**--**</color>'': 뒤 인자를 path로만 해석한다. ===== Examples ===== <code bash> 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 </code> ===== Config ===== * editor 선택 우선순위: ''$SUDO_EDITOR'' -> ''$VISUAL'' -> ''$EDITOR'' * 위 환경 변수가 없으면 ''sudoers''의 ''editor'' 설정을 따른다. * ''sudoedit''는 editor를 invoking user 환경으로 실행하므로, root 전용 shell rc나 root home에 의존하는 workflow와는 다르게 동작할 수 있다. ===== Troubleshooting ===== * ''sudoedit: command not found'' 또는 별도 binary가 없으면 보통 ''sudo -e''로 같은 동작을 사용할 수 있다. * symbolic link나 user writable directory 경로는 policy와 sudo 버전에 따라 편집이 차단될 수 있다. * 임시 파일 저장 후 원본 반영 단계에서 실패하면 경고와 함께 수정본이 temporary file로 남을 수 있다. * ''sudoedit'' 자체가 ownership 또는 setuid 오류를 내면 sudo package 설치 상태가 깨졌을 가능성이 크다. ===== Compatibility ===== * ''sudoedit''는 사실상 ''sudo'' front-end의 edit mode다. * local man page 기준으로 symbolic link 편집 차단은 sudo 1.8.15+, user writable path 제한은 1.8.16+ 설명이 포함돼 있다. * 배포판 policy plugin이나 ''sudoers'' 설정에 따라 허용 옵션과 password 동작이 달라질 수 있다. ===== Deprecated / Legacy ===== * privileged file을 직접 ''sudo vim /etc/file'' 형태로 여는 방식은 plugin, swap, backup, shell escape 관점에서 더 위험할 수 있다. * ''sudoedit''가 있는 환경에서는 config file 수정에 edit mode를 우선 고려하는 편이 안전하다. ===== Related ===== * ''sudo -e''는 ''sudoedit''와 같은 의미다. * syntax 검증이 필요한 정책 파일은 ''visudo'' 같은 전용 validator와 함께 쓰는 편이 낫다. * GUI editor를 쓸 때는 ''--wait'' 성격의 옵션이 필요할 수 있다. ===== Help ===== ++++ man sudoedit synopsis and edit behavior | <code text> sudoedit [-ABknS] [-C num] [-D directory] [-g group] [-h host] [-p prompt] [-R directory] [-r role] [-t type] [-T timeout] [-u user] file ... -e, --edit Edit one or more files instead of running a command. 1. Temporary copies are made of the files to be edited with the owner set to the invoking user. 2. The editor specified by the policy is run to edit the temporary files. 3. If they have been modified, the temporary files are copied back to their original location and the temporary versions are removed. </code> ++++ ===== See Also ===== * [[sudo]] ===== History ===== * codex:: 2026-07-16 Added sudoedit reference page with safe edit workflow, environment selection, and troubleshooting notes. {{indexmenu>sudoedit:#}} /home/u613600155/domains/cli.zerotymer.net/public_html/data/pages/sudoedit.txt 마지막으로 수정됨: 2026/07/16 05:18저자 writer